Syntax and Basics
The building blocks of every Python program: syntax rules, names, values and simple input/output.
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.
Variables
A variable is a name bound to an object; assigning again simply re-binds the name.
Constants
Python has no true constants — by convention, names in UPPER_CASE are treated as fixed values.
Keywords
Reserved words with special meaning that can't be used as names — like if, for, def, class and return.
Identifiers
The rules for naming variables, functions and classes.
Type Conversion
Convert between types explicitly with int(), float(), str(), bool(), list() and friends.
Input and Output
Read text with input() and write with print() — plus formatting options.
break, continue and pass
break leaves a loop, continue skips to the next iteration, pass does nothing (a placeholder).
Dictionary and Set Comprehensions
Build dicts and sets in one expression, like list comprehensions.
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.