---
title: "Defining a Function with Parameters"
description: "Giving a named block of code a job of its own and passing values into it, so the same steps run on different data."
canonical: https://lightmysky.com/learn/computing/defining-a-function-with-parameters-mt_pyo7yBg4H3
source: https://lightmysky.com/learn/computing/defining-a-function-with-parameters-mt_pyo7yBg4H3.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`.

# Defining a Function with Parameters

Giving a named block of code a job of its own and passing values into it, so the same steps run on different data.

Subject: Computing · Area: Programming · Ages 15 to 16
Page: https://lightmysky.com/learn/computing/defining-a-function-with-parameters-mt_pyo7yBg4H3

## Ready when they can

- Define a function and call it more than once with different arguments
- Decide which values the function needs as parameters
- Replace a repeated block with a single call

## Lesson: Name it once, call it anywhere

A procedure packs a few steps under one name so you can reuse them. Define singBingo once, then call it three times, and the computer still runs every line each time. You type less, yet the machine does the full job.

**Example.** Parameters let one recipe serve many callers. sayHello(person) greets Jackson, Mr H or Stranger depending on the value handed in. One greet replaces three copied print lines.

Design the inputs from what callers need, with few, clear names. reportGrade takes a student name and a count correct, like Sally with 27, where the score is (correct out of 30) times 100, turning 27 into 90. The count and order of values at the call must match the names in the definition.

**Tip.** Name each procedure for what it does, not how it works. When a fix lands in one place, every call benefits.

**Recap.** Pack repeated steps into a named procedure, feed each call through parameters, and call it wherever you need it.

## Practice

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

## Needs first

- [Traversing a List to Build a Result](https://lightmysky.com/learn/computing/traversing-a-list-to-build-a-result-mt_lusbjHFt95)

## Opens up

- [Return Values and Variable Scope](https://lightmysky.com/learn/computing/return-values-and-variable-scope-mt_jivtTHpZc7)
- [Classes and Objects: Bundling Data with Behaviour](https://lightmysky.com/learn/computing/classes-and-objects-bundling-data-with-behaviour-mt_kRvg7LZ_kk)
