Control flow & Conditions Flashcards
What is a conditional test?
An expression that can be evaluated as True or False.
A Boolean exptression.
What are Boolean values?
True and False
If age is greater or equal to 18, print “You can vote”, else print (“You can’t vote yet”)
if age >= 18:
print(“You can vote”)
else:
print(“You can’t vote yet”)
Which keyword you need to check two conditions are true in order to execute a block of code?
and
True and True is…
True
True and False is…
False
False and False is…
False
Which keyword you need to check if at least one of two conditions is true in order to execute a block of code?
or
True or True is…
True
True or False is…
True
False or False is…
False
Find if “U2” is in list rock_bands.
if “U2” in rock_bands:
….
Find if “U2” is not in list rock_bands.
if “U2” not in rock_bands:
….
Check if name_list is not empty
if name_list:
…