Loading...
Quiz: If, Elif, Else
Check your understanding of Python if, elif, else, logical operators, shorthand conditions, and nested ifs with this interactive MCQ quiz.
1.
What will the following code output?
python
4 lines
|16/ 500 tokens
1 2 3 4a = 5 b = 10 if b > a: print("b is greater than a")
Code Tools
2.
What will cause an IndentationError in Python?
3.
What is the output of this code?
python
8 lines
|32/ 500 tokens
1 2 3 4 5 6 7 8a = 10 b = 10 if b > a: print("b is greater") elif a == b: print("Equal") else: print("a is greater")
Code Tools
4.
What will this logical operator expression return?
python
5 lines
|22/ 500 tokens
1 2 3 4 5a = 20 b = 10 c = 30 if a > b and c > a: print("Both conditions are True")
Code Tools