Functions and modules are how Python programs stay small, readable and reusable instead of turning into one long, brittle script. This beginner course teaches you to define and call functions, pass default and keyword arguments, gather variable arguments with *args and **kwargs, document with docstrings, reason about scope, and import both standard-library and your own modules. It builds the function-and-module skills assessed by the Python Institute PCEP certification and finishes with a hands-on lab of ten programming exercises with full solutions.
Watch the free preview
Why functions? Defining and calling with def — free to watch, no account needed.
What you'll learn
- Define functions with def, parameters and return values to package reusable logic
- Call functions correctly using positional, keyword and default arguments
- Capture variable-length inputs with *args and **kwargs
- Write clear docstrings and reason about local versus global scope
- Import standard-library modules and write, import and reuse your own module
Syllabus
Defining and Calling Functions
Why functions? Defining and calling with defFree preview
Parameters, arguments and return values
Arguments in Depth
Default and keyword arguments
Variable arguments — *args and **kwargs
Docstrings and Scope
Docstrings — documenting your functions
Scope — local and global variables
Modules and the Standard Library
Importing modules — math, random and aliases
Writing your own module
Lab — 10 Programming Exercises & Solutions
Programming Exercises 1–5
Programming Exercises 6–10