Functions and Program Design Python lessons
Parameters, return values, default and keyword arguments, scope, decomposition, and reusable code.
6 exercises6+ conceptsBeginner → interview context
Start this topicWHAT YOU WILL LEARN
Core concepts
Reuse a prime-checking functionCalculate tax with an optional rateAverage any number of valuesCreate a discount closureGenerate a countdownLog a function call with a decorator
REUSABLE THINKING
Problem-solving patterns
- function · return
- default argument · function
- args · unpacking
- closure · scope
- generator · yield
LESSON OUTCOME
What this topic builds
Learn the idea once, trace it through two verified cases, then explain why your approach works.
ORDERED LESSONS
All 6 lessons in this topic
Work from top to bottom to build each concept gradually.
- #031Reuse a prime-checking functionStarterPremium
Call a reusable function for a prime input.
- #032Calculate tax with an optional rateStarterPremium
Calculate a bill using the standard 18 percent rate.
- #033Average any number of valuesBeginnerPremium
Average four ratings through a variadic function.
- #034Create a discount closureBeginnerPremium
Create and apply a 15 percent festival discount.
- #035Generate a countdownBeginnerPremium
Generate a countdown from five through zero.
- #036Log a function call with a decoratorBeginnerPremium
Add a simple audit line whenever the greeting function runs.