RANIARANIA Academy

Functions & Modules — the Basics

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.

Python: Foundations BEGINNER · 150 min · Certificate on completion · 3 CPD points

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 preview15 min
Parameters, arguments and return values15 min
Arguments in Depth
Default and keyword arguments15 min
Variable arguments — *args and **kwargs15 min
Docstrings and Scope
Docstrings — documenting your functions15 min
Scope — local and global variables15 min
Modules and the Standard Library
Importing modules — math, random and aliases15 min
Writing your own module15 min
Lab — 10 Programming Exercises & Solutions
Programming Exercises 1–515 min
Programming Exercises 6–1015 min