Module 6

Reusing functions

Calling functions multiple times.

Write once, use many times

The real power of functions is reuse. Define a function once, then call it with different values.

Python
def square(n):
    return n * n

print(square(2))
print(square(5))
print(square(10))
4 25 100
Your task

Reuse a function

  • Define square(n) and print square(2), square(5).