Python Tutorial · Python Basics · Lesson 2 of 42

Python Get Started

Install Python, run a script and use the interactive shell.

Install Python

Check whether Python is already installed by opening a terminal (Command Prompt on Windows) and typing:

python3 --version

If you see something like Python 3.12.3, you're ready. Otherwise download the latest version from python.org — on Windows, tick "Add Python to PATH" during installation.

Run a Python file

Python code is saved in files ending in .py. Create a file called hello.py:

hello.pyTry it yourself
print("Hello from my first Python file!")

Output

Hello from my first Python file!

Then run it from the terminal:

python3 hello.py

The interactive shell

Typing python3 with no file starts the interactive shell (REPL), where each line runs immediately — handy for quick experiments:

>>> 2 + 3
5
>>> print("Hi")
Hi
>>> exit()

Running code on this site

Every example on ReadyCamel has a Run button. Python runs right in your browser, so you can follow the whole tutorial without installing anything — but you'll want a local installation for real projects.

Test yourself

Which file extension do Python source files use?

  1. .pt
  2. .py
  3. .pyt
  4. .python
Show answer

Answer: .py