Skip to content

Latest commit

 

History

History
 
 

04-Call-a-function

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

tutorial https://www.youtube.com/watch?v=NU5iW_bWwmY

04 Calling a function

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 * edge

If you want to use that function to calculate the area of a square with:

length = 3
edge = 6

You need to do something like this:

area = calculate_area(3,6)
# The value of area will be set to 18

📝 Instructions:

Create 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)

img

💡 Hint:

Call the calculate_area function three times, one per each square, passing the length and edge of each square.

📺 9 min video about functions in python