Lesson 1 of 30

In progress

Course progress

Python

Install Python and run your first program

Install Python 3.12 or newer on Windows, macOS or Linux, run your first program, and understand what the terminal is telling you.

The first wall in learning Python is rarely the language. It is the black window, the command that is not found, and a file that will not run. This lesson gets you past that wall once, so every later lesson is about ideas rather than setup.

What you will learn

  • Install a current Python 3 on Windows, macOS or Linux.
  • Run code two ways: in a file, and in the interactive prompt.
  • Recognise the three setup errors that catch almost every beginner.

What Python actually is

Python is a program that reads a text file and does what the text says. That is the whole trick. You write instructions in a file ending in .py, and the Python program, called the interpreter, carries them out one line at a time.

Think of a recipe written in a language the cook understands. The recipe is your .py file. The cook is the interpreter. If the recipe says "add salt" and there is no salt in the kitchen, the cook stops and tells you which line went wrong. That message is a traceback, and later in this module you will learn to read it calmly.

Install Python 3 on your computer

Python 3.12 or newer is fine for this track. The examples use nothing that changed recently, and they also run on 3.13 and 3.14.

On Windows, open the Microsoft Store and install Python 3, or download the installer from python.org. If you use the installer, tick Add python.exe to PATH on the first screen. That checkbox is the difference between python working and a "not recognised" message.

On macOS, Python 3 is often already present. Open Terminal and type python3 --version. If the number starts with 3, you are ready. If macOS offers to install developer tools, accept it, or install Python from python.org.

On Linux, use your distribution’s package manager. On Ubuntu or Debian, sudo apt install python3 is enough. Never remove the system Python: your desktop may depend on it.

Check the result in a terminal:

python3 --version

You should see something like Python 3.12.4. On Windows the command is usually python --version. If python3 is not found on Windows, try py --version.

Run your first program

Create a folder for your work, then a file called hello.py inside it. Put these two lines in the file and save it.

Code
Code runs on the Java or .NET runtime, not in a browser tab. Copy this example into your editor and run it there.



Press Run to see the output.

Run it from a terminal in that folder:

python3 hello.py

The output is two lines: Hello from Python and 5. print displays a value. 2 + 3 is calculated first, then the result is displayed.

You can also type Python directly into the interpreter. Run python3 with no file name and you get a prompt of three arrows. Type 1 + 1 and press Enter. This is useful for quick experiments, but it forgets everything when you close it, so real work belongs in a file.

Use one folder per practice project, and always run Python from inside that folder. Most "file not found" problems are really "I am in the wrong folder" problems.

The three errors that stop beginners

The first is command not found. The interpreter is installed but not on your PATH. Reinstall with the PATH option, or use the py launcher on Windows.

The second is wrong folder. You see can't open file 'hello.py': [Errno 2] No such file or directory. The file exists, but not in the folder your terminal is sitting in. Use cd to move into the folder, then run the command again.

The third is the wrong quotes. print("hello") works; print(“hello”) uses curly quotation marks copied from a word processor and fails. Always type code in a plain editor.

A very common first mistake is typing python hello.py while the file is saved as hello.py.txt, because Windows hides known file extensions. If the name in the folder ends in .txt, rename it to end in .py and turn on file extensions in Explorer.

Write a program that prints your name, then prints the result of 10 * 3. Run it from a terminal, not from the interactive prompt.

Show solution

Your file should look like this. The exact greeting does not matter, but both lines must be present.

Code
Code runs on the Java or .NET runtime, not in a browser tab. Copy this example into your editor and run it there.



Press Run to see the output.

Run it with python3 hello.py. You should see your name followed by 30.

Recap

  • Python is an interpreter that runs the instructions in a .py file.
  • Install Python 3.12 or newer, and make sure python3 --version works in a terminal.
  • Run files from the folder that contains them; most early errors are setup errors, not logic errors.

Next, you will store values in variables so your programs can remember things instead of printing the same fixed text.

Do I need an editor like PyCharm or VS Code?
No. Any plain text editor works, including Notepad or TextEdit in plain-text mode. A code editor adds helpful colouring and error hints, and VS Code with the Python extension is a good free choice once you are comfortable, but it is not required for this track.
Why does my computer say python3 is not found on Windows?
Windows usually installs the command as `python`, or provides the `py` launcher. Try `python –version` and `py –version`. If both fail, reinstall from python.org and tick the option that adds Python to PATH.
Can I learn Python only on a phone?
You can read every lesson and run the examples on this page, because they execute in your browser. Installing Python and working with files needs a computer, so borrow one for the later modules. The ideas transfer either way.

Full syllabus

Progress is saved in this browser only. No account, no email.

Admin

About the author

Admin

Instructor and technical writer at tutorials.in

Writes beginner lessons for tutorials.in. Each lesson is checked against the language or tool documentation, and examples are run before publishing.

Reviewed by the editorial team before publishing. Last updated November 16, 2026.