Your First Python Program
Prerequisites: Installing Python
Create a file named hello.py containing:
print("Hello, world!")
Run it from a terminal, in the same folder as the file:
python3 hello.py
Expected output
Hello, world!
print() is a built-in function that displays text on the screen — it's
usually the very first tool reached for when checking what a program is
actually doing.
Common mistakes
- Forgetting the quotes around text —
print(Hello)looks for a variable namedHello, not the text "Hello", and fails. - Running
python3 hello.pyfrom a different folder than the one the file is saved in.