Before every launch, someone must check the hatch. Rocket's program asks, "Hatch sealed?" When Kai types YES in capitals, the program says to stop.
"But I said yes!" Kai says. Raven grins. "What do you notice? We fixed this same problem in week five."
Rocket thinks hard. Nova gives a tiny nod. "Would you like a hint? Make the answer small letters before you check it."
An if can check what the user typed.
Use lower so YES, Yes and yes all match.
answer = input("Hatch sealed? ")
if answer.lower() == "yes":
print("Safe to launch")
else:
print("Stop! Check the hatch") | The screen shows | The user types |
|---|---|
| Hatch sealed? | YES |
| Safe to launch |
| The user types | Does the program say Safe to launch? |
|---|---|
| Yes | ? |
| no | ? |
| yes please | ? |
| yES | ? |
fuel = int(input("Fuel units? "))
if fuel >= 100:
print("Full tank")
elif fuel >= 40:
print("Enough for one trip")
else:
print("Refuel first") | The screen shows | The user types |
|---|---|
| Fuel units? | 55 |
| Enough for one trip |
pods = int(input("Pods free? "))
if pods == 0:
print("Station full")
elif pods < 3:
print("Few pods left")
else:
print("Plenty of room") | The user types | Does it say Plenty of room? |
|---|---|
| 5 | ? |
| 3 | ? |
| 2 | ? |
| 0 | ? |
Great choices! Tomorrow you will build a whole launch checklist program.