Program, to find the area of rectangle, square, circle and triangle by accepting suitable input parameters from user.
name = input("Enter the name of shape whose area you want to find:")
if name == "rectangle":
l =
int(input("Enter rectangle's length: "))
b =
int(input("Enter rectangle's breadth: "))
rect_area = l * b
print(f"The area of
rectangle is {rect_area}.")
elif name == "square":
s =
int(input("Enter square's side length: "))
sqt_area = s * s
print(f"The area of
square is {sqt_area}.")
elif name == "triangle":
h =
int(input("Enter triangle's height length: "))
b =
int(input("Enter triangle's breadth length: "))
tri_area =
0.5 * b * h
print(f"The
area of triangle is {tri_area}.")
elif name == "circle":
r =
int(input("Enter circle's radius length: "))
pi = 3.14
circ_area
= pi * r * r
print(f"The
area of triangle is {circ_area}.")
else:
print("Sorry!
This shape is not available")
OUTPUT
Enter the name of shape whose area you want to
find:hexagon
Sorry! This shape is not available
Enter the name of shape whose area you want to
find:rectangle
Enter rectangle's length: 24
Enter rectangle's breadth: 35
The area of rectangle is 840.
Enter the name of the shape whose area you want
to find: triangle
Enter triangle's height length: 45
Enter triangle's base length: 32
The area of triangle is 720.0.
Enter the name of the shape whose area you want
to find: square
Enter square's side length: 67
The area of square is 4489.
Enter the name of the shape whose area you want
to find: circle
Enter circle's radius length: 45
The area of circle is 6358.500000000001.