You’ve been calling procedures since Week 5 — print, len, input — without naming what you were doing. Today we name it: give a procedure some values, get a result back, and don’t worry how.
Focus on calling a procedure and using what it returns. We’ll write our own in 3.12. Enrolled in our Runestone course? Open it from there so your progress counts.
Still in Programs, opening Week 3. Loops and lists let you do a lot — but your programs are getting long and repetitive. Procedures are the tool for managing complexity: package a job once, call it by name whenever you need it.
len a list, and it hands back
a number. You have never once looked at how len counts — and you
didn’t need to.
That’s a procedure call: values go in as arguments, a result comes out as a return value, and the messy middle is hidden. Today you learn to read that shape everywhere — including calls nested inside other calls.
A procedure is a named block of code you can run by calling it. You pass it arguments (the values in the parentheses), it does its job, and it may hand back a return value.
| Call | Arguments in | Returns |
|---|---|---|
| len(scores) | a list | how many elements |
| max(scores) | a list | the largest element |
| round(3.7) | a number | the nearest whole number |
scores = [85, 90, 78] print(len(scores)) # 3
# a list of 3 scores # len(scores) runs FIRST → 3, # then print(3) shows it
Hover or tap a line to light its twin. Nested calls run from the inside
out. len(scores) becomes 3 first; then print
receives that 3. Whenever you see calls inside calls, evaluate the innermost one first.
Feed a value to a built-in procedure and see what it returns — without ever seeing its insides. Then try a nested call and watch it evaluate inside-out.
Five questions. For nested calls, evaluate the innermost one first. Then pick your answer.
Every print, every input, every
len is a procedure someone else wrote, tested, and handed you as a black box. Modern
software is procedures calling procedures calling procedures — almost none of which any one
programmer wrote. You built a working program in Week 2 on top of code you’ll never
read, and that’s not cheating; it’s the whole design.
This is abstraction doing its most important job: letting humans build things far bigger than any one person could hold in their head. The catch is trust — when a black box has a bug or a bias, everyone standing on it inherits it. You’ll see that tension again with libraries (3.16) and AI (Unit 8).
def.DISPLAY(LEN(list)) is
a guaranteed question. Inside-out, every time.