Hello World in Python
Your first Python program - the classic Hello World example with Docker setup
Every programming journey starts with Hello World. Python makes this incredibly simpleāit’s just one line.
The Code
Create a file named hello.py:
| |
That’s it. One line. This simplicity is what makes Python so beloved as a first programming language.
Understanding the Code
print()- A built-in function that outputs text to the console"Hello, World!"- A string literal (text) enclosed in double quotes- No semicolons needed - Python uses newlines to separate statements
- No boilerplate - Unlike Java or C, there’s no class or main function required
Running with Docker
The easiest way to run this without installing Python locally:
| |
Running Locally
If you have Python installed (Python 3.6+):
| |
Expected Output
Hello, World!
Why Python is Different
Compare Python’s Hello World to other languages:
| Language | Lines of Code | Boilerplate Required |
|---|---|---|
| Python | 1 | None |
| Java | 5 | Class, main method |
| C | 4 | includes, main function |
| C++ | 5 | includes, namespace, main |
This minimal boilerplate is a core Python philosophy: simple things should be simple.
Key Concepts
- Python is interpreted - No compilation step; source runs directly
- Indentation matters - Python uses whitespace to define code blocks (you’ll see this in later tutorials)
- Dynamic typing - No need to declare variable types
- Interactive mode - You can also run
pythonand typeprint("Hello, World!")directly
The Interactive Shell
Python also has a REPL (Read-Eval-Print Loop). Try it:
| |
Then type:
| |
This interactive mode is great for experimenting and learning.
Next Steps
Continue to Variables and Data Types to learn about storing and manipulating data in Python.
Running Today
All examples can be run using Docker:
docker pull python:3.13-alpine