Getting your computer ready
Problem
What you need
To write and run programs, you need two things:
- Python: the
pythoninterpreter that runs programs, and the standard libraries. - An editor for your code. You could write a program in Notepad, but an editor for programmers colors the code, gives you hints and shows errors as you type.
If you do not have a computer you can install programs on yet, an online editor is enough for the first few days: search the web for online Python. The tasks from the "Language basics" module work there too. For the bigger programs later on, you will need an installation.
The idea
Install Python 3.12
We use Python 3.12 or newer (3.13, 3.14): everything in the course runs on them. Download it from python.org, in the Downloads section.
- Windows: download Python for Windows and run the installer. If it asks whether to add Python to the
PATH("Add python.exe to PATH"), turn the option on. - macOS: download the installer for macOS and run it.
- Linux: Python is usually already on the system (on Ubuntu 24.04 it is 3.12). If it is not there, this is how you install it on Ubuntu:
sudo apt install python3Check. Open a new terminal (on Windows: PowerShell or Command Prompt) and type the first line on Windows, or the second one on macOS and Linux:
python --versionpython3 --versionYou should see the version number. The numbers after 3.12 may be different, and the version may also be newer:
Python 3.12.7On macOS and Linux the command is python3, because there is often no python command there. Wherever the course says python, you type python3.
The idea
Choose an editor
Two good free options:
- Visual Studio Code with the Python extension from Microsoft. It is light and works for other languages too. You run the program with the triangle at the top right (Run Python File).
- PyCharm from JetBrains: an editor made specially for Python. The free version is enough for the whole course. You run the program with the green triangle at the top.
Which editor you choose does not matter much. What matters more is that you get used to one and use it every day.
See it
Your first program on your computer
Make a folder for the course, and in it a file named shop.py with this content:
print("Hello!")Hello!That is the whole program: one line, with nothing around it. In the terminal, go to the folder (cd and the path to it) and run (on macOS and Linux: python3 shop.py):
python shop.pyPython checks the file, translates it and runs it right away. No other file appears in the folder.
More precisely, if you are curious
- On Windows, the
py shop.pycommand works too. It runs the newest Python that is installed. - The
pythoncommand without a file (python3on macOS and Linux) opens a mode where you type line by line and see the result right away. It is handy for trying out one line. You leave it withexit(). - You choose the file name. Do not name it after a Python library (
random.py, for example): when the program brings in that library, Python will take your file instead.
- If the Windows terminal shows question marks or odd symbols instead of characters such as
€oré, the terminal is not set up for UTF-8. Typechcp 65001and run the program again. Editors usually do not have this problem.
Try it
Change it and run it again
Add a second line that prints "Your computer is ready.", save the file and run the program again. You should see:
Hello!Your computer is ready.If you see only "Hello!", the file most likely is not saved. Here is the whole program, in case you get stuck:
print("Hello!")print("Your computer is ready.")Why a change you have not saved does not reach the program:
print("Hello!")print("Your computer is ready.")Step by step, in words
- The editor and the file on disk both have only the first line.
- You run python shop.py: Python reads the file on disk.
- You add a second line in the editor. The file on disk is still the old one.
- You run it without saving: you still get only "Hello!".
- You save (Ctrl+S): the editor writes the text to the file on disk.
- You run it again: now the program sees the second line too.
The idea
When it will not start
- "'python' is not recognized…" (Windows) or "command not found" (macOS, Linux): the terminal cannot find Python. Close it and open a new one, because the old one does not see the changes from the installation. On macOS and Linux type
python3, and on Windows trypyas well. - "Python was not found; run without arguments to install from the Microsoft Store…" (Windows): Windows has its own shortcut named
pythonthat sends you to the Microsoft Store. Install Python from python.org or turn that shortcut off: Settings → Apps → Advanced app settings → App execution aliases. - "can't open file … No such file or directory": you are running from the wrong folder, or the file has a different name. Go into the folder with
shop.py(cdand the path to it). SyntaxErroror another message with a line number (line 1): Python has started and read the file, so the installation is fine. Compare your code with the example character by character.
In short
In short
- You need Python 3.12 or newer and an editor: VS Code with the Python extension, or PyCharm.
python --version(python3 --versionon macOS and Linux) shows whether Python is installed.python shop.pychecks the file, translates it and runs it.
- If the terminal cannot find the command, open a new terminal.
Next comes the lesson on how to solve a task before a single line of code is written.