Python — installation and the first run
Welcome to the first lesson of the Python tutorial! On this page you will learn how to:
- check whether Python is already on your computer (Windows, macOS, Linux),
- install Python if you do not have it,
- set up the Thonny environment (ideal for beginners and for working with the micro:bit),
- write your first program.
1. Is Python already installed?
Before you download the installer, check whether Python may already be installed on your system. In many cases (especially on macOS and Linux), Python is already there.
✔ Windows — checking the Python version
Open Command Prompt (CMD) or PowerShell and type:
python --version
If that does not work, also try:
py --version
If you get an answer like:
Python 3.11.2
then Python is already there.
If you get an error such as:
"python is not recognized..."
then Python is not installed or has not been added to PATH.
✔ macOS — checking the Python version
On macOS open Terminal and enter:
python3 --version
If you get a version (e.g. Python 3.9.6), an installation exists.
Older macOS versions have Python 2 preinstalled, so the command python may show:
Python 2.7.x
Modern Python programs use only Python 3, so look at the result for python3.
✔ Linux (Ubuntu, Mint, Debian...) — checking the version
On Linux systems Python is practically always installed. To check:
python3 --version
or, on an older system:
python --version
If the terminal reports a version, Python is there. If it reports an error, you can install it with the command:
sudo apt install python32. Installing Python
If Python is not installed, download it from the official site:
□ Download Python (python.org)
During the installation be sure to turn on the option:
✔ Add Python to PATH
This makes it possible to run Python from any folder.
Python also comes with a simple environment called IDLE, but for beginners and for working with the micro:bit a much better tool is:
3. Installing and setting up Thonny
Thonny is a simple and clear environment made especially for beginners. It comes with a built-in Python interpreter and is ideal for working on Windows, macOS and Linux.
Which version of Thonny should you download?
The official site thonny.org offers several versions:
- Thonny for Windows (the best option for Windows 10/11)
- Thonny for macOS (Apple M1/M2/M3 processors or Intel — check which one you have)
- .deb / .tar.gz versions for Linux distributions (Ubuntu, Mint, Debian...)
If you are not sure what to choose — always pick the first or the recommended version in the list.
Does Thonny come with Python?
Yes! Most Thonny installations include their own Python version (Python 3.10+). For students and beginners this is perfect, because you do not have to install Python separately.
Note: Thonny versions 4.0 and later always come together with modern Python versions and are fully suitable for beginner work, the micro:bit and basic projects.
Installing on Windows
- run the installer (e.g. thonny-4.x.x.exe)
- click Next → Install
- wait for the installation to finish
- start Thonny (a shortcut will appear on the Desktop)
Installing on macOS
- download the version for Apple Silicon (M1/M2/M3) or Intel, depending on your model
- drag Thonny into the Applications folder
- start it from Launchpad
Installing on Linux
- recommended: use the DEB package for Ubuntu/Mint/Debian
- or install it from the terminal:
sudo apt install thonny
After starting it you will see two areas:
- the upper part — the space for writing programs
- the lower part — the Python console (shell)
You are ready for your first Python program!
Should you install Thonny if Python already exists?
It very often happens that Python is already installed on a computer — by hand, together with some other program or through the Windows Store. If you already have Python, Thonny can use it in two ways:
- use its own built-in Python (recommended for beginners)
- use the Python that is already installed on the system
How do you check whether Python exists on the system?
Open a terminal / command line and type:
python --version
or
python3 --version
What should you do if Python exists?
- there is no need to uninstall anything
- by default Thonny will use its own Python, which is the safest for students
- if you want, you can change the interpreter in: Tools → Options → Interpreter
A recommendation for students
Let Thonny use its built-in Python — that way everything is always set up correctly, without manual PATH settings and possible errors.

4. The first program in Python
The best-known first program in the world is Hello, World!. In the Thonny environment type the following code:
print("Hello, World!")
Then click Run ▶. If you get text output in the lower part of the screen — you have successfully run your first Python program!

5. Comments in Python
Comments are lines of code that Python skips. They are written with the # symbol and are used to explain what the program does.
# This is a comment
print("Hello!")
Using comments is very important in programming, because it makes code easier to understand, especially when you work in a team or come back to a project after a long time.
6. Arithmetic operations in Python
Python can do mathematical operations such as addition, subtraction and multiplication. Try the following examples:
print(5 + 3)
print(10 - 4)
print(6 * 7)
print(20 / 5) # division
print(10 // 3) # integer division
print(10 % 3) # remainder
print(2 ** 4) # power
Program output:
8
6
42
4.0
3
1
16
You can change the numbers and experiment as much as you like — that is the best way to learn. Notice that / always gives a decimal number (4.0), while // gives a whole number.
7. Mini practice tasks
Try to solve these short tasks. If you do not succeed the first time, never mind — you will try again.
- Write a program that prints your name.
- Write a program that prints three messages, each on a separate line.
- Make a mini calculator that adds two numbers.
An example calculator:
a = 5
b = 7
print("The sum is:", a + b)
In the next lesson you will learn how the user can enter numbers with the input() statement, and how the program works with them.
What next?
This was the first lesson of the Python basics. In the next lesson we move on to your first interactive programs and the input() statement.
If you want extended tutorials on visualization and the micro:bit, also see:
Recommended environments and resources for learning Python
When you are just starting to learn Python, it is very important to choose a simple and clear environment. Here are the environments that are ideal for beginners, as well as the best online resources for practice and learning.
1. Which environment should I choose at the start?
There are several options, and it all depends on your needs:
✔ Thonny — the best choice for beginners
It is recommended for the start because it has:
- a simple interface,
- clear error messages,
- a built-in debugger,
- support for MicroPython and the micro:bit.
✔ IDLE — comes with the Python installation
IDLE is useful for the very first steps. It is very simple and starts as soon as you install Python. It is good for shorter programs and for getting to know the basic syntax.
✔ Visual Studio Code
Later, when you have mastered the basics, you can move on to VS Code because it offers:
- automatic code completion,
- projects with several files,
- extensions for Python, Django, Flask, MicroPython.
✔ Online environments (no installation)
If you want to start right away without installing programs:
- replit.com – a free online editor, ideal for students and small projects. It needs no installation and keeps your projects online.
- trinket.io – a very simple editor in the browser; excellent for practising loops, branching and basic tasks.
- pythonide.online – the simplest Python interpreter for very quick code tests.
- Petlja.org – interactive exercises for students (in Serbian), working directly in the browser without installation.
All these options are free and especially suited to beginners who want to start right away, without setting up and installing a Python environment.
2. Recommended resources for learning Python
Petlja.org — an excellent resource for students
Petlja has several courses that are ideal for primary and secondary school students (in Serbian). I especially recommend:
- The Python handbook for 6th grade — interactive lessons and tasks.
- Tasks and competition examples for those who want more.
The advantage of Petlja is that you can write and test code directly in the browser — without installation.
The official Python documentation
Good for later stages of learning, when you want more detailed explanations:
YouTube tutorials
Many channels cover the basics and more advanced topics. Good choices:
- "M Coding" — simple and clear explanations
- "Tech With Tim" — excellent projects
- "Bro Code" — Python tutorials for beginners
3. Resources by area
MicroPython
- The official MicroPython documentation
- The MicroPython editor in Thonny
- Petlja micro:bit courses – excellent for younger students
micro:bit
- Introduction to the micro:bit (SR)
- The MakeCode online editor (no installation)
- MicroPython for the micro:bit in Thonny
Processing (Java/Processing.py)
- Introduction to Processing
- The Processing IDE
- P5.js for working on the web
4. A recommendation: how should a beginner choose the right environment?
If you are a student in grades 6–8 or an adult beginner:
- For the easiest start: Thonny
- For working without installing anything: Petlja.org or Replit
- For more serious work: VS Code
- For the micro:bit and MicroPython: Thonny
An ideal learning path:
- Thonny (the first weeks)
- Petlja practice tasks
- Replit for small projects
- VS Code when you are ready for bigger programs
5. What should you choose if you have a weaker computer?
If your computer has little RAM, an older processor or Windows that runs slowly — the good news is that Python can run even on very weak machines. Here are the recommendations:
The best choices for weaker computers:
- Thonny — runs fast, takes very little memory and is ideal for beginners.
- pythonide.online — the lightest online interpreter (nothing is installed).
- trinket.io — works directly in the browser, without loading the system.
- Petlja.org — runs tasks directly in the browser, even on older computers.
And what should you avoid?
- VS Code — can be slow and demanding for weaker computers.
- PyCharm — an excellent editor, but it needs a lot of RAM and processor power.
Conclusion: If your computer runs slowly, it is best to start with Thonny or not to install anything at all — use Replit, Petlja or Python IDE Online.
IDLE — how to use it and how to start it on Windows and Ubuntu
IDLE is the official, simple Python environment that comes with every Python installation. It is very light, starts quickly and is ideal for beginners who want a clean, clear tool without extra settings.
✔ What does IDLE offer?
- The Python Shell — you can write and run commands right away.
- An editor for writing programs (.py files).
- The option "Run → Run Module (F5)" for running programs.
- Automatic syntax colouring.
- A built-in (basic) debugger.
How do you start IDLE on Windows 10/11?
If you installed Python from python.org, IDLE is installed automatically.
1. Starting IDLE (the easiest way)
- Click the Windows Start menu.
- Type IDLE.
- Choose:
IDLE (Python 3.x 64-bit)
2. Starting it from the Python folder
If you do not see it in the menu:
- Go to:
C:\Users\NAME\AppData\Local\Programs\Python\Python3x\ - Run: idle.bat
3. How do you make a new Python file?
- File → New File
- Type the Python program
- Save it with the
.pyextension - Run it with F5
How do you install and start IDLE on Ubuntu Linux?
Ubuntu does not install IDLE automatically, but you can install it with one command.
1. Installing IDLE
sudo apt update
sudo apt install idle3
2. Starting IDLE
- In Activities / Search type: IDLE
- Or start it from the terminal:
idle3
How do you use IDLE? (a short guide)
The Python Shell
When you open IDLE, the Shell appears first. There you can run short commands right away:
>>> 2 + 3
5
>>> print("Hello!")
Hello!
The editor for programs
For real programs open the editor:
- File → New File
- Type the code
- File → Save
- Run the program: Run → Run Module (F5)
When should you use IDLE?
- On very weak computers
- For school exercises
- For shorter and simpler programs
- When you want the simplest possible environment without any setup
