← Algorithms Foundations
1 / 25
Lesson 1 — Find the maximum
An algorithm is a recipe
An algorithm is a precise, step-by-step recipe for solving a problem. One of the most common recipes is the scan: walk through a list once and remember the best value seen so far. To find the largest number, start with the first item as your "best", then compare every other item against it.
best = 3
if 9 > best:
best = 9 # new champion
Why it matters: built-ins like max() do exactly this inside. Writing it yourself teaches the "keep track while you loop" pattern you will use in almost every algorithm.
Want it another way?
Task
Without using max(), finish the loop so largest() returns the biggest number. Expected: 9, then 42.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.