Beginner·8 min·basics · functions
Functions
Functions
A function is a named, reusable block. def defines one. return hands a value back.
Default arguments
excited=False is a default. Callers can override it by name.
Try it
- Write a function
area(width, height)that returns the area of a rectangle. - Add a default for
heightso callingarea(5)returns the area of a 5×5 square.