Beginner Fundamentals

Syntax

Python’s syntax is minimal. No curly braces {} and no semicolons to end lines.

Indentation matters

In Python, indentation defines code blocks. Other languages use braces; Python uses whitespace.

if 5 > 2:
    print("Five is greater than two")

The space before print isn’t cosmetic — it’s required. The standard is 4 spaces.

if 5 > 2:
print("error")  # IndentationError

One statement per line

x = 1
y = 2

To break a long line, use \ or parentheses:

total = (1 + 2 +
         3 + 4)

Case sensitive

name, Name, and NAME are three different variables.