Lesson 2: Functions & Output

Today we structure our program and learn how to save our scientific results.

Session Goals
  • Master defining functions to organize code.
  • Create the mandatory main.py file structure.
  • Write the speed estimate to result.txt with correct formatting.

The result.txt Requirement

At the end of the 10-minute run, your program must write a file named result.txt containing only your estimated speed.

Crucial Rule: The file must contain only the number (e.g., 7.1235). Do not include units like "km/s" or extra text.

Formatting Precision

Your result needs to be precise. We use Python's string formatting to ensure we have enough significant figures.
"{:.4f}".format(value) keeps 4 decimal places.

Mission Control Interface

Loading Python environment...
Output Terminal
Ready to execute...