TExcelTAD
Home › Python › Python Get Started

Python Get Started

You can start writing Python right now in the playgrounds on this site. Sooner or later, though, you will want Python on your own computer so you can run scripts, work with files and install packages. This lesson shows both.

Is Python already installed?

Many Linux and macOS systems ship with Python 3. Open a terminal (Command Prompt or PowerShell on Windows) and ask for the version:

bash · try it yourself
python3 --version
Python 3.12.4

On Windows the command is usually python or py instead of python3. Your version number may differ — anything from 3.10 upwards works for this course.

Installing Python

System Recommended way
Windows Download the installer from python.org and tick "Add python.exe to PATH"
macOS Installer from python.org, or brew install python
Linux Your package manager, e.g. sudo apt install python3

Tip: On Windows, the Microsoft Store version of Python also works well for learning.

Writing your first script

A Python program is just a text file whose name ends in .py. Create a file called hello.py in any text editor (VS Code, PyCharm, or even Notepad) with this content:

python
print("Hello from a file!")

Then run it from the terminal, in the folder where you saved it:

bash · try it yourself
python3 hello.py
Hello from a file!

The interactive shell (REPL)

If you run python3 with no file name you get the interactive shell, also called the REPL (Read–Eval–Print Loop). You type one statement, press Enter, and see the result immediately. It is perfect for quick experiments.

bash
$ python3
>>> 2 + 3
5
>>> "py" * 3
'pypypy'
>>> exit()

The >>> is the prompt. In the shell you don't even need print() — the value of an expression is shown automatically. In a script file, you do need print() to see anything.

Running code in this course

Every example marked with a ▶ Run button is a complete Python program. Try this one — it prints the version of Python that is running it:

python · try it yourself
import sys

major = sys.version_info.major
print("Running Python", major)
print("Is it Python 3?", major == 3)
Running Python 3
Is it Python 3? True

The first line, import sys, loads a module from the standard library. Modules have their own lesson later on.

Python as a calculator

Python evaluates arithmetic just like a calculator, following the normal order of operations:

python · try it yourself
print(7 + 5)
print(10 - 4 * 2)
print((10 - 4) * 2)
print(7 / 2)
12
2
12
3.5

Choosing an editor

Editor Why people like it
VS Code + Python extension Free, fast, great debugger and linting
PyCharm Community Full Python IDE with smart refactoring
IDLE Comes with Python, very simple
Jupyter Notebook Mix code, output and notes — popular for data work

Note: Whatever editor you choose, configure it to indent with 4 spaces. That is the standard style for Python code.

Test yourself

What file extension do Python scripts use?

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

What does the >>> symbol indicate?

  1. A comment
  2. A shell redirect
  3. The interactive Python prompt
  4. A syntax error