Question | Click to View Answer |
What does the following code print to the console? if 2 == 2:
print("ice cream is tasty!")
|
The code block in an |
What does the following code print to the console? if "cat" == "dog":
print("prrrr")
else:
print("ruff")
|
The boolean condition ( |
What does the following code print to the console? if 5 > 10:
print("fan")
elif 8 != 9:
print("glass")
else:
print("cream")
|
If the boolean condition associated with the |
What does the following code print to the console? name = "maria"
if name == "melissa":
print("usa")
elif name == "mary":
print("ireland")
else:
print("colombia")
|
If the boolean conditions associated with the |
What does the following code print to the console? if 88 > 100:
print("cardio")
|
Nothing is printed. The boolean condition ( |
What does the following code print to the console? hair_color = "blue"
if 3 > 2:
if hair_color == "black":
print("You rock!")
else:
print("Boring")
|
This is an example of a nested The boolean condition for the inner |
What does the following code print to the console? if True:
print(101)
else:
print(202)
|
In previous examples, we've used boolean expressions that evaluate to |
What does the following code print to the console? if False:
print("Nissan")
elif True:
print("Ford")
elif True:
print("BMW")
else:
print("Audi")
|
"Ford" is printed. The first |
What does the following code print to the console? if 1:
print("1 is truthy!")
else:
print("???")
|
1 does not equal |
What does the following code print to the console? if 0:
print("huh?")
else:
print("0 is falsy!")
|
0 is considered falsy in a boolean context. There are other values that are considered falsy in a boolean context and we'll cover those in future quizzes. |