Learn
Introduction to Functions
Introduction to Functions

A function is a collection of several lines of code. By calling a function, we can call all of these lines of code at once, without having to repeat ourselves.

So, a function is a tool that you can use over and over again to produce consistent output from different inputs.

We have already learned about one function, called print. We know that we call print by using this syntax:

print(something_to_print)

In the rest of the lesson, we’ll learn how to build more functions, call them with and without inputs, and return values from them.

Instructions

Watch the gif, in which an add_one_side function is applied to different shapes (inputs), transforming them into new shapes (outputs).

Press Next to learn about functions in Python and how to create them.

Folder Icon

Sign up to start coding

Already have an account?