Quiz: Decisions
Eight questions on truth values, comparisons, and, or and not and on decisions with if, elif and else in Python.
What type does the value of 5 > 3 have?
A comparison answers a yes-or-no question, here with True. True and
False are truth values, and their type is called bool.
What is the difference between x = 5 and x == 5?
= assigns and so changes x, == compares and gives True or False
without changing anything.
What does print("Yes" == "yes") print?
Texts are only equal if they match character by character, also in upper
and lower case. With "Yes".lower() == "yes" the comparison would give
True.
What does this program print?
age = 15
student = True
print(age >= 18 or student, not student)age >= 18 is false, student is true, and for or one true side is
enough, so True. not student turns True around and gives False.
Which conditions are true if number = 12? (several are right)
12 can be divided by 2 without a remainder, lies between 10 and 20 and is in
the list. 12 is not greater than itself, and not turns the true comparison
number == 12 into False.
What does this program print?
temperature = 25
if temperature >= 10:
print("mild")
elif temperature >= 20:
print("warm")
else:
print("cold")Python takes the first condition that is true, and 25 is at least 10. It no longer checks the other conditions after that, which is why with ranges the check with the highest value belongs at the top.
What does this program print?
answer = "no"
if answer == "yes" or "y":
print("Agreed.")
else:
print("Declined.")Python reads the condition as (answer == "yes") or "y". To the right of
the or there is no comparison but the text "y", and a text that is not
empty counts as true. Correct would be answer == "yes" or answer == "y" or
answer in ["yes", "y"].
What does this program print?
def size(number):
if number > 10:
return "large"
if number > 5:
return "medium"
return "small"
print(size(8), size(20))8 is not greater than 10 but greater than 5, so size(8) gives the text
"medium". At 20 the first condition is true, and return ends the
function at once with "large".
Download with answers: CSV Anki
Details
- Level
- Beginner
- Modules
- Digitization and Programming
- In learning paths
- Python for beginners
- Code
3442- Updated
- 1 November 2026
- Status
- published