Skip to content
UPEEC

Syntax and Basics

The building blocks of every Python program: syntax rules, names, values and simple input/output.

Beginner
Comments 0

Python reads top to bottom, uses indentation for blocks and needs no semicolons or type declarations. These topics cover the rules every line of Python follows.

Sub-topics (9)

Python Syntax

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

Beginner♥ 0🔖 0💬 0

Variables

A variable is a name bound to an object; assigning again simply re-binds the name.

Beginner♥ 0🔖 0💬 0

Constants

Python has no true constants — by convention, names in UPPER_CASE are treated as fixed values.

Beginner♥ 0🔖 0💬 0

Keywords

Reserved words with special meaning that can't be used as names — like if, for, def, class and return.

Beginner♥ 0🔖 0💬 0

Identifiers

The rules for naming variables, functions and classes.

Beginner♥ 0🔖 0💬 0

Type Conversion

Convert between types explicitly with int(), float(), str(), bool(), list() and friends.

Beginner♥ 0🔖 0💬 0

Input and Output

Read text with input() and write with print() — plus formatting options.

Beginner♥ 0🔖 0💬 0

break, continue and pass

break leaves a loop, continue skips to the next iteration, pass does nothing (a placeholder).

Beginner♥ 0🔖 0💬 0

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.