Lesson 3 of 3
Composing functions
The real payoff of functions: name a business rule once, reuse it everywhere. A duplicated calculation is a bug waiting to happen.
A short function, an explicit name, a single responsibility — the foundation of maintainable code.
🎯 Exercise
Define apply_discount(price, percent) returning round(price * (1 - percent / 100), 2). Then compute final = apply_discount(120, 25) and print final.
PRO lesson
This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.
Discover PRO →