Python Square Function
def / returnPractice

Define square(n) — return n²

Write a function, call it, and visualise the square area it produces. A function is a machine: put n in, get n² out.

Picture this: in n, out n²

One parameter, one return.

ninput
→
n * ninside
→
returnsquare

Diagram — call square

n=5 square(n) 25

In easy words: What is this task?

You create a function that takes a number and returns that number multiplied by itself.

Where this is used

Used in area formulas, physics equations, score metrics, and many math-heavy program calculations.

Theory: def and return

  • def square(n): declares a function named square that takes one argument.
  • return n * n sends the computed value back to the caller.
  • The function doesn't print — the caller decides what to do with the returned value.

Real world: area calculator

A flooring app calls square(side) to get room area in sq ft. The same function powers dozens of room cards — one definition, many calls.

Square area visualizer

n=?
n²
square(?) = ?
1def square(n):
2return n * n

Example Program

1def square(n): return n * n
2print(square(6))