Skip to content
beginner to intermediate

Functions and Modules

Organize Python into reusable functions and modules, manage scope, and build programs that are easier to extend.

Tutorials

Articles in Functions and Modules

Follow these lessons in order, or jump directly to the topic you need.

A breathtaking sunrise over a vast mountainous landscape with clear skies.
beginner
6 min read

Defining Functions in Python

A function turns a block of code into a named tool you can call by name. Write the steps once, give them a name, and reuse them across your program instead…

Read tutorial
Explore summer relaxation with a teal swimsuit covered in sand on a sunny beach.
beginner
7 min read

Importing Modules in Python

An import statement is not a magic incantation. It is a name-resolution request: you tell the running Python program, "find this module and make its names…

Read tutorial
A vivid close-up of a single yellow sow thistle flower in bloom against a dark background.
beginner
14 min read

Practice Exercises: Functions

Reading about functions teaches you the rules. Writing them teaches you the mechanism. These python functions exercises are built so you run code, inspect…

Read tutorial