← All Exercises

Python Default Arguments

basicpython~10min

Background

Default arguments make functions more flexible by allowing callers to omit optional parameters with sensible defaults.

Problem

Write a function that formats a greeting with configurable greeting word, punctuation, and uppercase options using default arguments.

Input

A name string and optional formatting parameters.

Output

A formatted greeting string.

Sample tests

Sample 1

Input: "Alice"
Expected: "Hello, Alice!"

Your solution

Learning objective

Learn default parameter values, keyword arguments, and the mutable default argument pitfall.