Q2 - Selection Statements

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:35 PM on 9/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

An if statement does not need to have an else clause.

True/False

True

2
New cards

An IF block can have between 0 and infinite numbers of ELSE-IFs

True/False

True

3
New cards

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

4
New cards

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

5
New cards

Consider the expression: value >= 30


Which if the following is equivalent to this expression?

value > 30 OR value == 30

6
New cards

It is not possible to put an IF block inside another IF block

True/False

False

7
New cards

The Boolean expression ((A and B)) and (not(A and B)) evaluates to:

false in all cases

8
New cards

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

9
New cards

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

10
New cards

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