Bugsy
Explains
3 hearts left

Functions

New idea

A recipe with a name

You have already used print many times without knowing how it works inside. You just give it something and it does the job. That is a function, a named recipe.

You write the recipe once with def, and give it a name. The things it needs are called parameters, listed in brackets. The answer it hands back uses return.

def double(n): makes a recipe called double that takes one input, n. Then return n * 2 hands back twice that number.