Python: Control flow Flashcards
What is a Boolean expression?
A statement that can either be true or false
What does this variable mean?
[==]
Equals
What does this variable mean?
!=
Not equals
What does this code do?
type(random_variable)
Checks what type is the variable
Ex: checks if it’s assigned to a text or Boolean
Define following relational operators
1. >
2. >=
3.<
4.<=
- Greater than
- Greater than or equal to.
- Less than.
- Less than or equal to.
What does the following Boolean operator do?
And
Combines two Boolean expressions and checks if BOTH are true or false
What does the following Boolean operator do?
or
Combines two expressions and checks if either is true
What does the following Boolean operator do?
not
When applied to any Boolean expression, it reverses Boolean value
What does else statement do?
Describe what we want our code to do when certain conditions are not met.
Ex:
if weekday:
print(“wake up at 6:30”)
else
print(“sleep in”)
What does elif (else if) statement do?
Checks another condition after the previous [if] statements conditions aren’t met.