Welcome to the Python Management Movement (Conditional Statements) Quiz!
In Python, management movement (conditional statements) gives logical construction of determination making. The quiz will take a look at your understanding of if, elif, else, and different management movement ideas in Python.
Every query is designed to strengthen your problem-solving expertise. Let’s see how properly you already know Python’s decision-making buildings!
Desk of Contents:
- Python quizzes for novices sequence
Conditional Statements Quiz
Quiz Questions:
1. What would be the output of the next code?
if x > 5:
print("Higher")
else
print("Smaller")
Reply
Higher
2. What key phrase is used for a conditional assertion in Python?
Reply
if
3. What can be printed?
num = 7
if num % 2 == 0:
print("Even")
else:
print("Odd")
Reply
Odd
4. What does elif
stand for?
Reply
else if
5. What would be the output?
x = 20
if x < 10:
print("Low")
elif x < 30:
print("Medium")
else:
print("Excessive")
Reply
Medium
6. Can you utilize a number of elif
statements in an if-elif-else construction?
Reply
Sure
7. What can be printed?
x = 15
if x > 10:
if x < 20:
print("Between 10 and 20")
Reply
Between 10 and 20
8. What occurs if no situation in an if-elif-else chain is true?
Reply
If there’s an else
, it executes. In any other case, nothing occurs.
9. What would be the output?
x = 5
y = 10
if x > y:
print("X is bigger")
elif x < y:
print("Y is bigger")
else:
print("Equal")
Reply
Y is bigger
10. What kind of values do conditional expressions consider to?
Reply
Boolean (True
or False
)
11. What can be printed?
x = 3
if x:
print("True")
else:
print("False")
Reply
True
(as a result of 3
is truthy)
12. What’s the right syntax for an if
assertion?
Reply
if situation:
assertion
13. What can be printed?
a = 0
if not a:
print("Zero")
Reply
Zero
14. What would be the output?
x = 100
if x > 50 and x < 200:
print("Legitimate")
Reply
Legitimate
15. What’s the results of this expression?
if 0:
print("Sure")
else:
print("No")
Reply
No
(as a result of 0
is falsy)
16. What occurs if we write an if
situation with out indentation?
Reply
IndentationError (Python requires indentation for code blocks)
17. What can be printed?
x = 20
if x == 10 or x == 20:
print("Match")
Reply
Match
18. How do you test if a quantity is detrimental?
Reply
if num < 0:
print("Unfavorable")
19. What can be printed?
x = 5
y = 10
if x and y:
print("Each True")
Reply
Each True
(since each x
and y
are truthy)
20. What would be the output?
x = None
if x:
print("Worth exists")
else:
print("No worth")
Reply
No worth
(as a result of None
is falsy)
How did you do? 🎯
- 18-20 right → 🏆 Glorious! You’re a Python features professional!
- 14-17 right → 👍 Nice job! Maintain training.
- 10-13 right → 🙂 Good, however there’s room for enchancment.
- Under 10 → 🤔 No worries! Evaluation the ideas and take a look at once more.