Space Python Loading Python…

Unit mix-up

Fix the codeEasy 3 stages

The flight dynamics team is checking the plan for a transfer to the Moon. One leg comes from a contractor's planning tool, and the total doesn't look right.

Predict what the code prints, find the leg that doesn't fit, fix the sum, then convert a lander's sensor readings yourself.

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.

Add up the three legs the way Python will. :,.0f prints the total with no decimals and commas between the thousands.

Predict, then run
Leave the program as it is

Finish stage 1 to unlock this stage.

Investigate. Find the variable that holds a distance in a different unit and store its name, as text, in odd_one_out. Then convert it: one mile is 1.609344 km. Store leg 2 in km, as a number, in leg_2_in_km.

Modify. Add a constant KM_PER_MILE = 1.609344 at the top and convert leg 2 before it's added. It must print:

Trajectory length: 386,294 km
Find the odd unit
Convert before adding

Finish stage 2 to unlock this stage.

A lander's altitude comes from its radar in metres, but the backup sensor reports the descent rate in feet per second, as many aircraft instruments do. Convert the rate to metres per second with a constant M_PER_FOOT = 0.3048, then print it and the time to touchdown:

Descent rate: 1.98 m/s
Touchdown in: 60.6 s

The time to touchdown is the altitude divided by the descent rate, both in metres.

Print the rate and the time
Convert with a constant
You're not logged in, so your progress is kept in this browser only. Log in to save it, and to use hints and solutions.

Hints

Basic Math Operations

basic-math-operations.py
# Mission fuel calculation
fuel_total = 1000
fuel_used = 350

fuel_remaining = fuel_total - fuel_used
print("Remaining fuel:", fuel_remaining, "liters")

# Engine power output
engines = 4
power_per_engine = 250

total_power = engines * power_per_engine
print("Total power:", total_power, "kW")

# Average speed calculation
distance = 1000
time_hours = 4

speed = distance / time_hours
print("Speed:", speed, "km/h")
Open the full example
script.py
PythonLn 1, Col 1Spaces: 4
Loading the Python environment…

Separate arguments with commas. They're passed on every Run as sys.argv[1:].