RANIARANIA Academy

Functions Deep Dive — Recursion, Scope & Functional Tools

Go beyond the basics of functions to master recursion and the call stack, the LEGB scope rules with global and nonlocal, lambdas and closures, and the functional trio of map, filter and reduce. Sharpen the higher-order-function fluency the Python Institute PCAP certification rewards, and learn when a comprehension beats a functional pipeline.

Watch the free preview

Recursion — base case and recursive case — free to watch, no account needed.

Python: Foundations INTERMEDIATE · 150 min · Certificate on completion · 3 CPD points

What you'll learn

  • Write correct recursive functions with a base case and a shrinking recursive case
  • Explain how the call stack drives recursion and why Python limits recursion depth
  • Resolve variable names using the LEGB rule and control scope with global and nonlocal
  • Use lambdas, higher-order functions and map, filter and reduce to transform data
  • Build closures that capture private state and choose between comprehensions and functional style

Syllabus

Recursion & the Call Stack
Recursion — base case and recursive caseFree preview15 min
The call stack and recursion limits15 min
Scope — LEGB, global & nonlocal
Scope and the LEGB rule15 min
The global and nonlocal keywords15 min
Lambdas & Functional Tools
Lambdas and higher-order functions15 min
map, filter and reduce15 min
Closures & Functional Style
Closures — functions that remember15 min
Comprehensions versus functional style15 min
Lab — 10 Programming Exercises & Solutions
Programming Exercises 1–515 min
Programming Exercises 6–1015 min