Conditionals in Python by Ctrl-Zombies
Categories: HomeworkConditionals homework in Python
Nested Conditionals Python Homework - CTRL Zombies
Python Popcorn Hack
weather = "rainy"
temperature = 50
# Fill in the blanks!
if weather == "sunny":
if temperature > 70: # fill in missing operator
print("Great day for a walk!") # fill in missing string
else:
print("Could be a bit chilly, wear a jacket!")
else:
if weather == "rainy": # fill in missing word
print("☔ Don't forget your umbrella!")
else:
print("Enjoy the nice weather!") # fill in missing string
Play in the rain
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
weather = "sunny"
has_umbrella = False
has_bike = True
if weather == "rainy":
if has_umbrella:
print("Take the bus")
else:
print("Call an Uber")
else:
if has_bike:
print("Bike")
else:
print("Walk")
Bike