Stage 1 · Lesson 3 of 10
Functions, classes and exceptions
Next, learn to structure your code. Functions take positional arguments (by order) and keyword arguments (by name). You will see *args and **kwargs, which collect extra arguments, in almost every framework.
A class groups data with the behaviour that uses it. cut the boilerplate for simple records. are how Python signals that something failed.
Raise a specific type, and catch only what you can handle, using try and except. Use with blocks so files and connections close even when something fails. Define your own exceptions, such as OrderNotFound, for errors your will later turn into a .
Common trapa bare except: or except Exception: pass, which swallows real bugs, typos included. You are left with silent wrong behaviour instead of a traceback, the error report that shows where it failed.
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