Stage 1 · Lesson 2 of 10
Python syntax and collections
Learn the Python you will write every day: variables, if statements, loops, functions and the four built-in . A list is an ordered group of items you can change. A tuple is a fixed group, like that should not change.
A dict maps keys to values, and looking up a key is fast (O(1) on average, meaning the time barely grows with size). A set keeps only unique items. A comprehension such as [u.email for u in users if u.active] builds a list in one line and replaces most hand-written loops. such as f"Hello {name}" format text.
Remember that indentation is part of the syntax. Also remember that 0, empty strings and empty lists all count as false in an if.
Common trapa default argument: def add(item, items=[]) shares one list across every call, so write items=None and create the list inside the function.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Python Fundamentals
Design Gurus · Beginner · $50
Python basics in a sensible order: collections, functions, classes and modules
- CourseFreeCS50's Introduction to Programming with Python
Harvard University · Beginner
Free Harvard course with real problem sets, and it teaches unit tests early
Practise
Keep handy
Also worth your time
The DNS, TCP, TLS and HTTP steps behind every request your backend will handle