# Using if/elif and chained conditions in pythons

## Quiz by Thanh Le

### Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

9 questions
• Q1
What is the correct syntax to use if/elif and chained conditions in Python?
if x = 5:
if x > 5:
if x == 5:
if x < 5:
30s
• Q2
How can you add more conditions to an if statement in Python?
elif
and
not
or
30s
• Q3
When using if/elif statements in Python, what is the purpose of the 'else' clause?
To break out of the entire if/elif block
To check if multiple conditions are true at the same time
To provide a default condition if none of the previous conditions are met
To skip the current condition and move on to the next one
30s
• Q4
What is the correct way to check if two conditions are both true in Python?
if x > 5, y < 10:
if x > 5 not y < 10:
if x > 5 or y < 10:
if x > 5 and y < 10:
30s
• Q5
In a chained condition statement using if/elif in Python, what does each 'elif' block do?
It indicates the end of the if/elif statement
It checks for an additional condition if the previous conditions were not met
It provides an alternative to the initial 'if' condition
It always executes regardless of previous conditions
30s
• Q6
When using if/elif statements in Python, what happens if multiple conditions are true in sequence?
Only the code block associated with the first true condition is executed
An error is raised due to conflicting conditions
All code blocks associated with true conditions are executed
The conditions are checked simultaneously and all true conditions are executed
30s
• Q7
In Python, what is the purpose of the 'if' statement?
To loop through a set of instructions repeatedly
To always execute a predetermined code block
To execute a block of code only if a certain condition is true
To define a function or method
30s
• Q8
How can you incorporate multiple conditions using 'or' in Python's if/elif statements?
if x < 0, x > 10:
if x < 0 or x > 10:
if x < 0 and x > 10:
if x < 0 not x > 10:
30s
• Q9
What is the correct way to nest if/elif statements in Python?
if x > 10: if y < 5: print('y is less than 5')
if x > 10: print('x is greater than 10') if y < 5: print('and y is less than 5')
if x > 10: print('x is greater than 10')elif y < 5: print('y is less than 5')
if x > 10: print('x is greater than 10')if y < 5: print('y is less than 5')
30s

Teachers give this quiz to your class