Calling Functions
Calling Functions
...
Modify the program
def maximize(...):
Write correct code ...
2. Re-use: Call the function with def distance(x1, y1, x2, y2):
different values for the x_diff = (x1 x2)
y_diff = (y1 y2)
parameters square_x = x_diff * x_diff
square_y = y_diff * y_diff
d1 = distance(8, 4, 7, 7)
d2 = distance(0, 0, 12, 5) return math.sqrt(square_x + square_y)
d3 = distance(5, 3, 9, 20)
A function call
Calling Functions
Call (aka invoke) a function def blah():
by writing its name ...
d = distance(8, 4, 7, 7)
followed by parentheses, ...