Lazo Lab Sign up

Read Python Like a Pro / Reading code

Lesson 4 of 10

Reading functions

When code calls a function, jump to its def, plug in the arguments, follow it to return, then jump back with the result. Functions are just named recipes.

Key points

  • Arguments fill the parameters in order
  • return hands back a value
  • Code after return in the same block doesn't run
def double(x):
    return x * 2

def add_one(x):
    return x + 1

print(add_one(double(5)))

Your turn

Write a function triple(x) and predict what print(double(triple(2))) shows before you run it.

Watch a video on thisOpens YouTube search results for “Reading functions” in a new tab

Quiz · +10 XP

What does the code print?

Log in to save progress and earn XP.