Assignment in a condition
A new crew member wrote the oxygen check in a hurry: if the sensor says LOW, switch to the backup supply. The code looks almost right, but Python won't even start it.
Predict what Python says, fix the errors one at a time, then write a check of your own.
Finish stage 1 to unlock this stage.
Don't run the code yet. Read it and decide what it will print. Write your guess in prediction, at the top, between the quotes. Then run it and compare.
Any guess passes this stage: the point is to think before you run. After you check, you'll see your prediction next to what Python printed.
Look closely at the if line and at the line under it.
This program never runs, and a program that doesn't run can't be checked. After you run it and read the error, put a # in front of each of the four lines of the if and else, then check: you'll see your prediction next to what Python said.
Finish stage 1 to unlock this stage.
Investigate. Store the name of the first error Python reports in first_error, as text. Then fix the =, run again and store the name of the next error in second_error.
Modify. Fix both errors. With oxygen_status set to LOW it must print:
Switch to the backup oxygen supply
Finish stage 2 to unlock this stage.
Write the check that runs before undocking. If the hatch sensor says CLOSED, print the first line; otherwise print the second:
Hatch sealed, ready to undock Close the hatch before undocking
With the hatch OPEN, as in the starter code, it prints the second one.
Hints
Basic if Statement
# Basic if statement in Python
# Apollo 13 oxygen tank pressure (psi)
tank_pressure = 732
if tank_pressure < 800:
print("WARNING: Tank pressure below nominal")
# ISS crew check before spacewalk
astronauts_available = 3
suit_checks_passed = True
if astronauts_available >= 2:
print("Enough crew for spacewalk")
if suit_checks_passed:
print("Suits verified - EVA approved")
# Voyager 1 signal strength
signal_strength = 0.00000000001
signal_threshold = 0.000000000001
if signal_strength > signal_threshold:
print("Signal acquired from Voyager 1")
# Multiple conditions with one if
fuel = 92
navigation = True
if fuel > 80 and navigation:
print("Course correction burn approved")
# Try changing values and run again
# What if tank_pressure = 900?
# What if suit_checks_passed = False?
# What if fuel = 60?
Separate arguments with commas. They're passed on every Run as sys.argv[1:].