HomeCourse › Module 05

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

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