BeginnerCoder

Lesson 23 — Memoization by hand

Cache results

Memoization means storing computed answers in a dict (a cache) so repeated work is instant.

Why it matters: it turns slow recursive functions (like Fibonacci) into fast ones.

Want it another way?
Task

Store each result in the cache, then print fib(30) and how many entries the cache holds.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with Python Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.