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
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.
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.