CHAPTER 02 · BEGINNER4 min read

Setup and your first saved program

Understand the interpreter, terminal, and editor, then run a saved Python file reliably.

Python 3.12+Free to readModule 1 of 13
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Choose a Python 3.12 or later interpreter and confirm its version.
  • Run a saved .py file from its containing directory.
  • Diagnose common differences between a terminal and the Python prompt.

01Give each tool one clear job

You will use three related tools. An editor changes a text file containing your instructions. The Python interpreter reads and executes those instructions. A terminal accepts commands that start programs and navigate folders. Some applications combine all three in one window, but their jobs remain distinct. Keeping that distinction in mind prevents many early mistakes.

Install Python 3.12 or later from python.org if it is not already present. Installer screens differ by platform and Python release, so use the official installation guidance linked below for your system. You can use IDLE, which accompanies many Python installations, or a plain text code editor. This course needs no third-party packages for the beginner lessons.

02Check which interpreter you are starting

Open a terminal and ask the interpreter for its version. On many Windows installations, py starts Python through a launcher or manager; on macOS and Linux, python3 is common. Some systems use python. Try the command appropriate to your installation and read the result. Use the same working command consistently throughout your exercises, substituting it wherever a lesson uses python.

These are terminal commands, not Python statements. Enter one applicable command rather than pasting both into a .py file. A version beginning with 3.12 or a later Python 3 version meets this course's requirement. If the terminal cannot find the command, return to the installation instructions; that message concerns how the system locates Python, not the contents of your program.

terminalShell
py --versionpython3 --version

03Save the source, then run the file

Create a folder for your lessons and save the following source as first_program.py. Check the full filename: a text editor may otherwise save first_program.py.txt. Save changes before running. From a terminal opened in that folder, run python first_program.py, replacing python with your working interpreter command. The filename is an argument telling Python which source to execute.

A script starts with a fresh execution each time you run it. Its output appears in the terminal, but the output does not become part of the source file. Change the message, save, and rerun to confirm you are editing the same file you are executing. A successful run should display both lines and then return control to the terminal.

first_program.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.

04Recognize the prompt you are using

Starting Python without a filename usually opens its interactive prompt, often marked by >>>. Here you enter Python expressions directly and get immediate feedback. The three greater-than signs are a prompt, not characters to type into a script. Use exit() to leave the interactive interpreter before entering a terminal command to run a file.

If Python reports that it cannot open a file, check the filename and terminal's current folder. If nothing changes after an edit, save the file and check its location. If a command such as python first_program.py produces a SyntaxError, you may be entering a terminal command at the Python prompt. Identify which tool is receiving your text before changing the program itself.

saved_check.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.
LET IT CLICK

The ideas worth keeping.

  • The editor writes code, the interpreter executes it, and the terminal starts programs.
  • Save a .py file and run it using the interpreter command that works on your system.
  • Check the prompt, saved contents, filename, and current folder before reinstalling anything.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

Run a saved receipt

Save receipt.py containing a heading and the calculated total for three items costing 4 each. Run it from your terminal using your installed interpreter. The expected lines are Receipt and 12.

your_turn_1.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.
Explore a worked solution
one_possible_solution.pyPython
print("Receipt")print(3 * 4)

The program contains Python only. The command to run receipt.py belongs in the terminal, and the result confirms both the correct file and interpreter were used.

02

Prove an edit reached the interpreter

Create version_check.py that prints Version A and 10 + 2. Run it, then edit it so it prints Version B and 10 + 5. Save and run again. Provide the final source.

your_turn_2.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.
Explore a worked solution
one_possible_solution.pyPython
print("Version B")print(10 + 5)

The final output is Version B followed by 15. Changing both a message and an expression helps reveal an unsaved file or a terminal pointed at another copy.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 3 answered
01You see >>> and enter python lesson.py, causing a SyntaxError. What is the likely issue?
02Your edited message does not appear when you rerun a script. Which check is most useful first?
03Which content belongs inside a .py source file?
⚡CODING CHALLENGE
🔒Required to Mark Lesson Complete

Run a saved receipt

Save receipt.py containing a heading and the calculated total for three items costing 4 each. Run it from your terminal using your installed interpreter. The expected lines are Receipt and 12.

EXPECTED OUTPUT
Receipt
3 * 4
challenge.pyPython 3
Ctrl + ↵
Execution Console
Click "Run & Verify" (or press Ctrl + Enter) to test your code against the challenge.

Keep exploring.

The official references behind this chapter, when you want a second angle or the full details.

One chapter closer.

Reading is a start. Trying it yourself makes the connection.

Solve the hands-on coding challenge in the knowledge section to verify your code and unlock chapter completion.