---
title: "Functions at Depth: Default and Keyword Arguments"
description: "Giving a parameter a default so callers can leave it out, and naming arguments at the call so their order stops mattering. This is how one function serves several jobs without a second copy of the cod"
canonical: https://lightmysky.com/learn/computing/functions-at-depth-default-and-keyword-arguments-mt_SR8RhRmYhz
source: https://lightmysky.com/learn/computing/functions-at-depth-default-and-keyword-arguments-mt_SR8RhRmYhz.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Functions at Depth: Default and Keyword Arguments

Giving a parameter a default so callers can leave it out, and naming arguments at the call so their order stops mattering. This is how one function serves several jobs without a second copy of the code.

Subject: Computing · Area: Programming · Ages 16 to 17
Page: https://lightmysky.com/learn/computing/functions-at-depth-default-and-keyword-arguments-mt_SR8RhRmYhz

## Ready when they can

- Write a function with a default parameter and call it with and without that argument
- Call a function with named arguments given out of order and predict the result
- Say why a default that is a shared collection can surprise the caller

## Lesson: One function, many ways to call it

Arguments passed by place are called positional. They land in the parameters in order, so greeting("Hiya", "Ash", 2) puts "Hiya" in msg, "Ash" in name and 2 in count. Arguments that name their parameter are called keyword. With names, order stops mattering, so greeting(count=2, name="Ash", msg="Hiya") prints Hiya Ash twice. When you mix the two, every positional value must come first.

**Example.** A default is a fallback value written in the definition, as in def greeting(msg, name="Friend", count=1). Calling greeting("Hi") prints Hi Friend once, using both defaults. Calling greeting("Hi", "Ash", 3) replaces them and prints Hi Ash three times. You must still pass every parameter that has no default, so greeting() with no arguments fails.

**Tip.** Never use a list as a default value. Python builds the default only once, so every call shares the same list. Items appended in one call are still there on the next call, which surprises the caller.

Defaults let one function serve several jobs without a second copy of the code. Common calls stay short while rare tweaks pass their own values, and the signature documents the normal choice. Style point: write greet(name="Ash") with no spaces around the equals sign.

**Recap.** Name arguments to escape order, give defaults for the usual values, and never default to a shared list.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Return Values and Variable Scope](https://lightmysky.com/learn/computing/return-values-and-variable-scope-mt_jivtTHpZc7)
- [Decomposing a Problem into Subprograms](https://lightmysky.com/learn/computing/decomposing-a-problem-into-subprograms-mt_P293LckCnd)
