Recall & Review
beginner
What does an
if statement do in Python?It checks a condition and runs a block of code only if that condition is true.
Click to reveal answer
beginner
What happens if the
if condition is false and there is no else block?The program skips the
if block and continues with the next code after it.Click to reveal answer
intermediate
How does an
elif statement work in an if-elif-else chain?It checks its condition only if all previous
if and elif conditions were false.Click to reveal answer
beginner
What is the role of the
else block in an if statement?It runs a block of code when all previous
if and elif conditions are false.Click to reveal answer
beginner
Consider this code:<br>
if x > 10:
print('Big')
elif x > 5:
print('Medium')
else:
print('Small')<br>What will print if x = 7?It will print
Medium because x > 10 is false but x > 5 is true.Click to reveal answer
What happens when the
if condition is true?✗ Incorrect
When the
if condition is true, only the code inside the if block runs.If all
if and elif conditions are false, which block runs?✗ Incorrect
The
else block runs when all previous conditions are false.Can an
if statement have multiple else blocks?✗ Incorrect
An
if statement can have only one else block.What does the
elif keyword mean?✗ Incorrect
elif means 'else if' and checks a new condition only if previous conditions were false.What will this code print if
score = 85?<br>if score >= 90:
print('A')
elif score >= 80:
print('B')
else:
print('C')✗ Incorrect
Since 85 is not >= 90 but is >= 80, it prints 'B'.
Explain how Python decides which block of code to run in an if-elif-else statement.
Think about the order Python checks conditions.
You got /4 concepts.
Describe what happens when an if condition is false and there is no else block.
What does the program do next?
You got /3 concepts.