How to Run Python Code

Option 1: In your browser (no installing)

The coding challenges in this course run Python inside your web browser. There is nothing to install. Open a challenge, type your code and press Run.

This is the fastest way to start, and it works on any laptop.

Option 2: On your own computer

When you want to build your own projects, install Python on your computer:

  • Go to python.org, open Downloads and install the latest Python 3.
  • On Windows, tick the box “Add Python to PATH” during installation. This lets you run Python from the terminal.
  • On most Linux systems and on macOS, Python 3 may already be installed.

To check that it works, open a terminal (Command Prompt on Windows) and type:

python3 --version

You should see something like Python 3.12.1. On Windows the command is often just python.

Running a Python file

Python code is saved in files that end with .py. Create a file called hello.py in any text editor (VS Code is a great free choice) and put this line in it:

print("Hello from my computer!")

Output

Hello from my computer!

Then run it from the terminal, in the same folder as the file:

python3 hello.py

The interactive shell

If you type just python3 and press Enter, you get the interactive shell. It shows >>> and runs each line as soon as you press Enter. It is handy for quick experiments. Type exit() to leave.

Tip: For this course you can stay in the browser. Install Python later, when you want to build things on your own.

HOME LEARN COMMUNITY DASHBOARD