Module 06 of 11

Functions & Scope

Lessons

About This Module

Once you can make decisions and repeat work, the next step is packaging that logic into reusable pieces. This module covers how to define functions, control where your variables live, and write functions flexible enough to take any number of arguments.

It starts with defining functions: parameters, default values, and return statements. From there it covers scope — the difference between local and global variables, and how Python decides which one a function actually sees. It continues with *args and **kwargs, for writing functions that accept a variable number of positional or keyword arguments, and closes with lambda functions, small anonymous functions often used with filter(), map(), and reduce().

Watch the lessons in order, then continue on to Modules, Packages & Environments.

Lessons

4 videos
01

Python Tutorial for Beginners 8: Functions

Defining your own functions, working with parameters and default values, and returning values back to the caller.

02

Local and Global Scope in Python | Local and Global Variables

How Python resolves variable names inside and outside of functions, and why relying on global state can cause hard-to-find bugs.

03

*args and **kwargs Multiple Examples

Letting a function accept an arbitrary number of positional arguments with *args and keyword arguments with **kwargs.

04

Lambda Functions in Python | filter, map, reduce

Writing small, anonymous functions with lambda, and using them alongside filter(), map(), and reduce() for quick data transformations.