Write a function that computes the area of a rectangle.
rectangle_area(width, height)
Return width * height.
rectangle_area(4, 5) // → 20
rectangle_area(10, 10) // → 100
rectangle_area(1, 1) // → 1
There's no trick here — the area of a rectangle is its width times its height, full stop:
def rectangle_area(width, height):
return width * height
The only thing worth internalizing at this stage is the shape every function in this course will follow: take some inputs as parameters, compute a value, return it (not print it — see the previous lesson). You'll build on this exact pattern for the rest of the course, just with more interesting computations inside.
def rectangle_area(width, height):
return width * height
Sign in to join the discussion.
No comments yet. Be the first to ask a question.
Press Run to execute your code, or Submit to test and complete this problem.