PyPython · Lesson 1 of 14

Hello, World!

Every coding journey starts with Hello World. It's tradition, hazing, and a sanity check all rolled into one.

In Python, printing to the terminal takes exactly one line. No imports, no class definitions, no semicolons. The print() function outputs text (or any value) to standard output and appends a newline automatically.

Python
print("Hello, World!")

Save that as hello.py and run it with python3 hello.py. That's it — you're a programmer. print() is more flexible than it looks: it accepts multiple arguments and lets you customize the separator and line ending.

Python
# Multiple arguments — joined with a space by default
print("Hello,", "World!")            # Hello, World!

# Custom separator
print("2024", "01", "15", sep="-")   # 2024-01-15

# No newline at end
print("Loading", end="...")
print("done!")                        # Loading...done!

# Print numbers and booleans directly
print(42)
print(3.14159)
print(True)
◆ Note
Python 3 print() is a function — print("hello"). Python 2 had print as a statement — print "hello". Python 2 reached end-of-life in 2020. Do not learn Python 2.