def function_name(parameter1, parameter2, ...):
Code to run
return result
Code and Return should be indented.
def volume(width, height, length):
return width * height * length
the function named 'volume' is defined.
print(volume(5, 8, 2))
80
Return is used to save a result for the next use. *
Print only shows the result once and does not save it.
def volume(width, height, length):
return width * height * length
volume1 = volume(5, 8, 2)
print(volume1)
80
def surface_area(width, height, length):
return 2 * (width * height + height * length + width * length)
print(surface_area(2, 4, 6))
88
area1 = surface_area(2, 4, 6)
print(area1)
88
Comments
Join the discussionNo comments yet. Be the first to comment.