Skip to content
UPEEC

Python Syntax

Indentation defines blocks, newlines end statements, and `#` starts a comment.

Beginner
Comments 0
if voltage > 5:          # a colon opens a block
    print("too high")    # the block is indented (4 spaces by convention)
print("done")            # back to the outer level
  • One statement per line; a long expression can continue inside (), [] or {}.
  • Names are case-sensitive: Count and count are different.
  • Style is guided by PEP 8 — tools like Ruff and Black apply it automatically.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.