Skip to content

Latest commit

 

History

History

03-Call-a-function

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
tutorial

03 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, width):
    return length * width

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

length = 3
width = 6

You need to do something like this:

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

📝 Instructions:

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

Squares

💡 Hints: