Space Python Loading Python…

Tank level

Write the codeEasy 2 stages

Every propellant tank on Python One reports two numbers: what it can hold and what's in it now. The crew doesn't want two numbers. They want to know how full the tank is.

Turn the readings into a percentage, then into the gauge the crew display shows.

Work out how full tank B is and print it as a percentage with one decimal place:

Tank B: 73.4%

Divide what's in the tank by what it can hold, then multiply by 100.

Print the fill percentage
Calculate from the readings

Finish stage 1 to unlock this stage.

The crew display draws each tank as a gauge of 10 segments: one # for every full 10% and a - for the rest.

Tank B: [#######---] 73.4%

Work out how many full tens the percentage has, then repeat "#" that many times and "-" for the rest, as with the alert banner's "=" * 30. A text can only be repeated a whole number of times, so turn the count into an int.

Draw the gauge
Works for any tank
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:].