Run Python for the first time

Basic python

Run Python for the first time

This page walks you through the different ways to execute Python. Whether you use Colab or a local setup, try the steps below in order.

Use the interactive mode (REPL) #

Type the following command in your terminal or PowerShell.

python3

If python3 is not found on Windows, try py or py -3.13. A prompt similar to this appears:

Python 3.13.0 (main, ...)
>>>

Type an expression to see the result immediately.

>>> 1 + 2
3
>>> "Hello" * 2
'HelloHello'

REPL stands for “Read Eval Print Loop”. It is perfect for quick experiments and is widely used in tutorials.

Press Ctrl+D (or Ctrl+Z then Enter on Windows) or type exit() to leave the REPL.

Code written in the REPL is not saved to a file. Move longer code into a script.

Create and run a script #

Create a file named hello.py in your editor and enter the code below.

print("Hello, Python!")

Save the file, switch to the terminal in the same directory, and run:

python3 hello.py

On Windows you can also run py hello.py. You should see:

Hello, Python!

Keeping your work in .py files makes it easy to review changes and use Git later.

Use the editor’s run feature (optional) #

Editors such as VS Code or PyCharm provide a temporary “Run” button even without saving. In VS Code:

  1. Type the code in the editor.
  2. Click “▶ Run Python File” in the top-right corner.

When running from an editor, its own directory can become the current working directory. Be mindful of file paths in programs that read or write files.

Checklist #

  • Ran simple calculations in the REPL and exited successfully
  • Created hello.py and executed it from the command line
  • Tried the editor’s run button (optional)

Try it yourself #

  • Write a script that prints your favourite message three times in a row.
  • In the REPL evaluate 5 ** 2 and confirm the result matches your expectation.

Once you are comfortable with execution, move on to explore numbers and operators.