1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
An if statement does not need to have an else clause.
True/False
True
An IF block can have between 0 and infinite numbers of ELSE-IFs
True/False
True
Consider two variables X and Y. If the values of X=5 and Y=10
if name == “main”:
if X < 0:
print (“Message A”)
else:
if X > Y:
print(“Message B”)
else:
print(“Message C”)
What is displayed as the result of the code being executed?
Message C
In the Python code below, if the user enters the word “latte”, what will be the output?
choice = input(“Enter what you would like to order: “)
match choice:
case “milkshake”:
print(“Your total would be $1.50”)
case: “fries”:
print(“Your total would be $1.00”)
case: “sandwich”:
print(“Your total would be $2.00”)
case(“Chocolate cookie”:)
print"(“Your total would be $0.50)
case_:
print(“No such item can be ordered”)
No such item can be ordered
Consider the expression: value >= 30
Which if the following is equivalent to this expression?
value > 30 OR value == 30
It is not possible to put an IF block inside another IF block
True/False
False
The Boolean expression ((A and B)) and (not(A and B)) evaluates to:
false in all cases
Given the code below, if the user enters “40” what will be the output?
if name == “main”:
ticket = int(input(“Enter your ticket number “))
if ticket < 0:
print(“Please vacate the premises”)
elif ticket >= 0 and ticket < 20:
print(“Please proceed to door 1”)
elif ticket >= 20 and ticket < 40:
print(“please proceed to door 2”)
elif ticket >= 40 and ticket < 60:
print"(“Please proceed to door 3”)
elif ticket >= 60 and ticket < 80:
print(“Please proceed to door 4”)
else:
print(“Please proceed to door 5”)
Please proceed to door 3
Imagine a game of Yahtzee where a roll of dice always returns an even number. Consider this code where “number” is a variable that stores the values of dice.
if name == “main”:
result = number % 2:
if result = 0
print(“TRUE”)
else:
print(“FALSE”)
What will the code display when ran?
TRUE
if X = 3, Y = 1, and Z = 5 then the following Boolean expression evaluates to true:
(X > 0) and (Y == 0) or (Z < 5)
False