Conditionals in Python by Ctrl-Zombies
Conditionals homework in Python
Nested Conditionals Python Homework
Python Popcorn Hack
weather = "rainy"
temperature = 50
# Fill in the blanks!
if weather == "sunny":
if temperature ___ 70: # fill in missing operator
print("") # fill in missing string
else:
print("Could be a bit chilly, wear a jacket!")
else:
if ______ == "rainy": # fill in missing word
print("☔ Don't forget your umbrella!")
else:
print("") # fill in missing string
Part A: Python Practice
Write a code cell that helps decide what type of transportation someone should take.
- If the weather is
"rainy"
:- If they have an umbrella -> print
"Take the bus!"
- If they don’t -> print
"Call an Uber!"
- If they have an umbrella -> print
- If the weather is
"sunny"
:- If they have a bike -> print
"Bike!"
- If they don’t -> print
"Walk!"
- If they have a bike -> print
Example Starter Code
weather = "sunny"
has_umbrella = False
has_bike = True
# Write your nested conditionals here!