Functions

This lesson will introduce functions in Python.

Function

A function in a programming language is a reusable block of code that will be executed when called. You can pass data to it and it can return data as well.

Think of a function as a box that performs a task. We give it an input and it returns an output. We don’t need to write the code again for different inputs, we could just call the function again.

Get hands-on with 1200+ tech skills courses.