pyPython Practice LabFrom first print to final round
TOPIC 05 OF 18

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 topic
WHAT 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.

  1. #031
    Reuse a prime-checking function

    Call a reusable function for a prime input.

    StarterPremium
  2. #032
    Calculate tax with an optional rate

    Calculate a bill using the standard 18 percent rate.

    StarterPremium
  3. #033
    Average any number of values

    Average four ratings through a variadic function.

    BeginnerPremium
  4. #034
    Create a discount closure

    Create and apply a 15 percent festival discount.

    BeginnerPremium
  5. #035
    Generate a countdown

    Generate a countdown from five through zero.

    BeginnerPremium
  6. #036
    Log a function call with a decorator

    Add a simple audit line whenever the greeting function runs.

    BeginnerPremium