Space Python Loading Python…

Duration formatter

Write the codeEasy 3 stages

The flight computer on Python One counts mission time the simplest way there is: seconds since launch. That's perfect for calculations and useless at a glance. Is 100000 seconds one day or three?

Turn it into the clock the flight controllers read, one step at a time.

Split the mission time into whole hours, the minutes left over and the seconds left over, and print:

27 h 46 min 40 s

// divides and keeps only the whole part; % gives what's left over. An hour has 3600 seconds and a minute 60.

Print hours, minutes and seconds
Calculate from elapsed_s

Finish stage 1 to unlock this stage.

Mission control shows time like a clock, two digits for every part. Change the print so it shows:

27:46:40

Every part gets two digits, so 3725 seconds would show as 01:02:05. In an f-string, {minutes:02d} pads a whole number with zeros to two digits.

Show it as a clock
Pad every part

Finish stage 2 to unlock this stage.

Long missions count days as well. Mission control displays often write elapsed time as days, a slash, then the clock: DDD/HH:MM:SS. Add the days, with three digits:

001/03:46:40

A day has 86400 seconds. Once the days are taken out, the hours are only what's left of the last day.

Add the days
Works for any mission time
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

Floor Division and Modulo

floor-division-modulo.py
# Floor division (//) and modulo (%)

# ISS completes one orbit every 92 minutes
# How many full orbits in 24 hours?
minutes_in_day = 24 * 60
orbit_period = 92

full_orbits = minutes_in_day // orbit_period
remaining = minutes_in_day % orbit_period

print("Full ISS orbits per day:", full_orbits)
print("Minutes into next orbit:", remaining)

# Mars signal delay: 1,124 seconds
# Break into minutes and seconds
signal_delay = 1124
minutes = signal_delay // 60
seconds = signal_delay % 60
print(f"\nMars signal delay: {minutes} min {seconds} sec")

# Distribute 50 rations among 6 crew members
rations = 50
crew = 6
per_person = rations // crew
extras = rations % crew
print(f"\nRations per astronaut: {per_person}")
print(f"Extra rations: {extras}")

# Check if a mission number is even or odd
mission = 42
if mission % 2 == 0:
    print(f"\nMission {mission} is even")
else:
    print(f"\nMission {mission} is odd")
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:].