Return to Dashboard

Module 8: Multiple Conditions - elif

Instructions:

Answer the following 10 multiple-choice questions.

You need to answer at least 6 questions correctly to pass this knowledge check.

You can attempt this check as many times as you need.

1. Which keyword is used in Python to check an additional condition *only if* the preceding `if` condition was false?

2. Consider the code:

temp = 25
if temp < 0:
    print("Freezing")
elif temp < 20:
    print("Cool")
elif temp < 30:
    print("Warm")
else:
    print("Hot")
What will be printed?

3. In an `if`/`elif`/`else` structure, how many blocks of code can be executed at most?

4. What is the primary role of the `else` block in an `if`/`elif`/`else` chain?

5. Can you have multiple `elif` statements following a single `if` statement?

6. What is required immediately after the condition in an `elif` statement?

7. Consider this code:

score = 75
if score >= 90:
    grade = 'A'
elif score >= 80:
    grade = 'B'
elif score >= 70:
    grade = 'C'
else:
    grade = 'D'
print(grade)
What will the output be?

8. Is an `else` block mandatory when using `if` and `elif`?

9. What happens if the code inside an `elif` block is not indented correctly?

10. If you have `if condition1: ... elif condition2: ... else: ...`, and both `condition1` and `condition2` are `True`, which block's code will execute?

Quiz Results

0%
0 / 10