Note 06: Functions¶
Functions package a useful task behind a name. They make programs easier to test, reuse, and explain.
def square(number):
return number * number
answer = square(7)
print(answer)
Vocabulary¶
- Parameter: the variable named in a function definition.
- Argument: the value supplied during a call.
- Return value: the result sent back to the caller.
Design Tip¶
A good beginner function usually does one clear job. If its description needs the word "and" several times, consider splitting it.