← Courses

Python for AI — Beginner Foundations

Data Science

Functions · Lesson 39 of 76

Functions

A function is a named block of code you can run whenever you want. Functions let you write logic once and reuse it — instead of copying the same lines everywhere.

You've used functions already: print() and len() are built-in functions. Soon you'll write your own.

Python

Think of a function as a small machine: you feed it inputs, it does a job, and it hands back a result. The next lessons show how to build your own.

Your turn: use the built-in max() function to print the biggest of 4, 9, 2.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →