Space Python Loading Python…

Log line format

Write the codeEasy 2 stages

Every system on Python One writes to the mission log, one line per event. Engineers search those logs, tools filter them by level, and alarms go off when an ERROR line appears. That only works if every line has exactly the same shape:

[T+00:12:05] INFO  Engines nominal

The time since launch in square brackets, the level, two spaces, then the message. Write the code that builds these lines from values, so nobody has to type them by hand.

The starter code gives you three values. Print them as one log line, in exactly this shape:

[T+00:12:05] INFO  Engines nominal

Use an f-string: put f right before the opening quote, and each variable in curly braces where its value goes. Note the two spaces after the level. Leave the three given lines as they are: a hidden test runs your code again with other values.

Print the log line
Build it from the values

Finish stage 1 to unlock this stage.

The mission clock doesn't give you text like "00:12:05": it gives three numbers. Print the same log line from them:

[T+00:12:05] INFO  Engines nominal

A plain {minutes} prints 12, but {seconds} prints 5, not 05. Add a format spec after a colon: {seconds:02} means "at least 2 characters wide, filled with zeros".

Print the log line
Build it from the clock
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

Text Formatting with f-strings

text-formatting-f-strings.py
# F-strings - modern text formatting
astronaut = "John Smith"
mission = "Mars Explorer"
days_in_space = 180

print(f"Astronaut: {astronaut}")
print(f"Mission: {mission}")
print(f"Duration: {days_in_space} days")

# We can also do calculations
print(f"That is {days_in_space / 30:.1f} months")
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:].