Functions: naming a piece of work
Once a program passes a few dozen lines, the same calculations start to repeat. A function packages a piece of work under a name so you can run it whenever you need it:
def area(width, height):
return width * height
print(area(3, 4)) # 12
room = area(5, 2.5) + area(2, 2)
print(room) # 16.5
def starts the definition. width and height are parameters: names that receive whatever values the caller passes in. return sends a value back to wherever the function was called, so area(3, 4) becomes 12 in the expression that used it.
Defining a function does not run it. Python only records the instructions; the body runs each time you call the function with parentheses.
Key idea: A good function does one job you can describe in a sentence. If describing it needs "and", it probably wants to be two functions.

