Concept

What is a function call stack?

Calling a function opens a new frame, binds your arguments to its parameters, runs the body, and sends a value back. Below is a real widget from epochai's own curriculum, not a diagram.

When you write def add(a, b): return a + b and then call add(3, 4), three things happen in order. First, a new call frame opens — think of it as a fresh, temporary workspace just for this call. Second, the arguments 3 and 4 get bound to the parameter names a and b inside that frame.

Then the function body actually runs, using those bound values. When it hits return, the function stops immediately and sends the result — 7, here — back to wherever the call happened. The frame then closes; a and b stop existing the moment the function returns, along with everything else local to that call.

This is what "the call stack" refers to: every time a function calls another function, a new frame stacks on top of the one that called it, and frames close in the reverse order they opened. It's why a variable inside one function is invisible to another — each call gets its own frame, with its own separate copy of its parameters and local variables.

Watch it happen

The same interactive widget epochai's own lessons use — live, not a recording.

Playing automatically. Every epochai lesson also has an Explore mode where you drive it yourself.

This is one line out of 49 free lessons

Module 1 — Programming Fundamentals — covers variables, control flow, loops, functions, and debugging. Free, no card required.