Menu

Selection (IF)

Card 1 of 13 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 13 cards in this set
What Python construct allows you to execute code based on certain conditions?
If statements
What will happen if an 'if' statement's condition is True?
The indented block of code underneath will execute
How do you start an 'else if' block in Python?
elif
What does the '>' operator do in Python?
Checks if the left value is greater than the right value
In Python, what does the '<=' operator mean?
Less than or equal to
What is the output of the expression '7 < 8' in Python?
TRUE
When is the code under an 'else' statement executed?
When the preceding 'if' statement condition is False
Which statement is true about 'else' in Python?
It provides an alternative block of code that runs if the 'if' condition fails
What must follow an 'if' keyword in Python?
A condition
What is one of the benefits of using selection in programming?
Allows the program to make decisions
What might you use to compare a variable to multiple different values in Python?
Multiple 'elif' blocks
In Python, how can you check if a number stored in a variable 'num' is not 10?
if num != 10:
What does '!=' mean in an if statement?
It checks if two values are not equal