Rocket has typed his welcome banner into the shell five times today, once for every crew member who arrived. "There has to be a faster way," he groans, stretching his fingers.
Raven flips back through her notebook. "What do you notice about the shell?" she asks. "Every time you press Enter, the line runs once and then it is gone. Nothing gets kept."
Nova projects a small picture of a folder. "Would you like a hint?" she asks. "Programmers write their lines in a file first. Then one command runs the whole file, as many times as you like."
Rocket opens a fresh window and decides to write the banner just once, then save it forever.
IDLE has two kinds of windows. The shell runs one line the moment you press Enter. It is great for quick experiments.
The editor is for programs. You type many lines, save them as a file ending in .py, and then run the whole file at once. Nothing runs while you type.
| Shell | Editor | |
|---|---|---|
| How it starts | Opens with IDLE | File, then New File |
| What you see | The >>> prompt | An empty page |
| When lines run | Each time you press Enter | When you choose Run Module |
| Good for | Quick tests | Programs you keep |
print("Mission Control online")
print("Crew ready:", 3)
print("=" * 20)
print("Let's build some tools.") Python runs a file from the top line to the bottom line, in order. When you choose Run Module, the shell restarts and shows a RESTART line with your file name. Your output appears below it:
Mission Control online Crew ready: 3 ==================== Let's build some tools.
Tracing means reading a program the way Python does: one line at a time, from the top. You write down what each line shows before you run it.
An empty print() shows a blank line. It is useful for spacing out a report.
print("CREW ROLL CALL")
print("-" * 14)
print("Rocket", "Raven", "Nova")
print()
print("Total crew:", 1 + 1 + 1) You wrote, saved and ran a real Python program. Tomorrow you will learn to leave notes inside your programs for other people, and for your future self.