Hello, World

The smallest Python program, and how print() writes output.

Runs in Zerethon IDE · Python 3.12 Official Python documentation ↗

A Python file runs from top to bottom. There is no main function to declare: every statement at the top level runs in order.

main.py
print("Hello, World!")
print("Sum:", 2 + 3)
print("a", "b", sep="-", end="!\n")

Output

Hello, World!
Sum: 5
a-b!
  • print() separates its arguments with a space and ends with a newline; change that with sep= and end=.
  • A line starting with # is a comment.
  • Indentation is part of the syntax: blocks are marked by indenting, usually 4 spaces.