Hello

Installing

Python can be installed through package managers. Or, it can be be downloaded from here.

# Linux
sudo apt update
sudo apt install python3
sudo apt install python-is-python3
# The last install is to use `python` instead of `python3`
# MacOS
brew install python
# Windows
winget install Python.Python.3

Verify the installation by the command python --version.

Hello World

Python is written in a text file with the extension .py. The program python runs the code. Put the following code in a file named hello.py, and run it with the command python hello.py.

# Content of `hello.py`
print("Hello World!")

The object print is a function. The object "Hello World!" is a string, that is, a sequence of characters. The character # and everything after it on the line is a comment, that is, it is ignored by the Python interpreter.

Tip

I recommend using a general-purpose text editor. If you do not already have an editor of choice, then I recommend VS Code.

REPL

The read-eval-print loop (REPL) is started by the command python without arguments in the shell. The REPL is useful for testing small code snippets and quick calculations.

python

Python 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World!")
Hello World!
>>> exit()