| tutorial | https://www.youtube.com/watch?v=NU5iW_bWwmY |
|---|
A function could receive zero parameters, and it always returns something, even if you don't explicitly add the return statement.
☝️ Click here to read more about functions
For example: a function that calculates the area of a square will be something like this:
def calculate_area(length, edge):
return length * edgeIf you want to use that function to calculate the area of a square with:
length = 3
edge = 6You need to do something like this:
area = calculate_area(3,6)
# The value of area will be set to 18Create a new variables named square_area1, square_area2, square_area3 and call the function calculate_area three times one for each square in the picture, for example:
# For the first figure:
square_area1 = calculate_area(4,4)Call the calculate_area function three times, one per each square, passing the length and edge of each square.
