Skip to content

Your own functions

Read · 1 of 4

def makes a function

def square(x): starts a function called square that takes one value (called x inside). return x * x sends the answer back.

Define it before you use it. Calling square(5) runs it with x = 5 and turns into 25.