Functions
Define your own reusable mini-tools. Arguments, return values, defaults, and the rules that keep functions honest.
Foundations 6 lessons ~50 min
Lessons in this module
- def — defining your own function · 8 min
Make a custom 'formula' you can call from anywhere in your code. - Returning multiple values & unpacking · 6 min
How to send back more than one thing — using tuples and dict returns. - Scope — where variables live · 7 min
Local vs global, why your variable disappeared after the function ran, and how to do this safely. - lambda, map, filter — the functional shortcuts · 7 min
Tiny one-line functions and a quick tour of map() and filter(). - Modules and imports — using other people's code · 7 min
import, from-import, aliases, and the difference between standard library and third-party. - Anatomy of a real script · 8 min
How professional Python scripts are organised — imports, constants, functions, and the if __name__ block.