Python BasicsCore· 25 min read

Installing & Running Python

Set up Python on your computer and run your first file.

What you will learn

  • Install Python
  • Run a .py file
  • Use the Python shell

Install Python

Download Python from python.org (get the latest version). During install on Windows, tick “Add Python to PATH”. Check it works in your terminal:

Terminal: check Python is installed
python --version
# or on Mac/Linux:
python3 --version

This command asks Python to tell you its version number. If you see something like Python 3.12.1, Python is installed and ready. If you instead see an error like “command not found”, Python is not installed (or not on your PATH) — reinstall and make sure to tick “Add Python to PATH”. The # line is just a comment reminding you that Mac and Linux often use the name python3 instead of python.

Note: Output: Python 3.12.1 (Your exact number may differ — any 3.x version is fine.)

Run a file

Real programs live in files so you can save and re-run them. Write your code in a file ending in .py (use VS Code), then run that file from the terminal.

hello.py
# hello.py
print("Python is running!")
print("2 + 3 =", 2 + 3)

This is the file you save. The first line is a comment naming the file. The two print() lines display text on the screen — the second one prints the words 2 + 3 = and then the answer to the sum 2 + 3 next to it.

Terminal: run the file
python hello.py
# Output:
# Python is running!
# 2 + 3 = 5

Here you tell Python to run the file: type python followed by the file name. Python reads the file top to bottom and runs each line, so you see both print lines appear. The # Output: comments just show what you should expect on screen.

Note: Output: Python is running! 2 + 3 = 5

Tip: Type python (or python3) with nothing after it to open the interactive shell — type code line by line and see results instantly. Type exit() to leave.

Q. What file extension do Python files use?

Answer: Python files end in .py and are run with the python command.

✍️ Practice

  1. Install Python and confirm the version command works.
  2. Create and run a hello.py that prints two lines.

🏠 Homework

  1. Install VS Code and run a Python file from it.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →