Question: Suppose you are working on a Python program to calculate the area of various shapes. Your program includes a function called calculate _ area (
Suppose you are working on a Python program to
calculate the area of various shapes. Your program
includes a function called calculatearea that takes
two parameters: length and width. Inside this function,
you want to calculate the area of a rectangle using the
provided parameters. However, you also have a
variable called pi defined outside of the function, which
is used to calculate the area of a circle.
Your task is to modify the calculatearea function so
that it can calculate the area of both rectangles and
circles. If the shape is a rectangle, it should return the
area of the rectangle. If the shape is a circle, it should
use the global variable pi to calculate and return the
area of the circle.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
