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

Functions and Program Design Python practice problems

Parameters, return values, default and keyword arguments, scope, decomposition, and reusable code.

12 exercises6+ conceptsBeginner → interview context
Start this topic
WHAT YOU WILL PRACTISE

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
PRACTICE OUTCOME

What this topic builds

Learn the idea once, use it across the exercises, and explain why your approach works.

ORDERED PRACTICE

All 12 problems in this topic

Work from top to bottom to build the concept gradually.

  1. #061
    Reuse a prime-checking function: Prime function true case

    Call a reusable function for a prime input.

    StarterPremium
  2. #062
    Reuse a prime-checking function: Prime function false case

    Call the same function for a composite input.

    StarterPremium
  3. #063
    Calculate tax with an optional rate: Standard tax

    Calculate a bill using the standard 18 percent rate.

    StarterPremium
  4. #064
    Calculate tax with an optional rate: Reduced tax

    Pass a reduced rate explicitly for a special product.

    StarterPremium
  5. #065
    Average any number of values: Four ratings

    Average four ratings through a variadic function.

    BeginnerPremium
  6. #066
    Average any number of values: One reading

    A variadic function also handles a single supplied value.

    BeginnerPremium
  7. #067
    Create a discount closure: Festival discount

    Create and apply a 15 percent festival discount.

    BeginnerPremium
  8. #068
    Create a discount closure: No discount

    A closure with zero percent returns the original price.

    BeginnerPremium
  9. #069
    Generate a countdown: Launch countdown

    Generate a countdown from five through zero.

    BeginnerPremium
  10. #070
    Generate a countdown: Immediate finish

    Starting at zero yields exactly one value.

    BeginnerPremium
  11. #071
    Log a function call with a decorator: Log a greeting

    Add a simple audit line whenever the greeting function runs.

    BeginnerPremium
  12. #072
    Log a function call with a decorator: Forward a spaced argument

    The wrapper forwards a full-name argument unchanged.

    IntermediatePremium