Computer Science, asked by manoharys2000, 3 months ago

Write a python program to find the area of square, rectangle and circle. Print the
results. Take input from user

Answers

Answered by goldenwind
7

op = input("For what shape are you trying to find the area of? Reply with "square" or "rectangle" or "circle :")

if op == "square":

side = input("side of the square(must be just a number) : ")

area = int(side) * int(side)

print(f" the area is: {area}")

elif op == "rectangle":

length = input("length of the rectangle (must be just a number): ")

breadth = input(" breadth of the rectangle:")

area = int(length) * int(breadth)

print(f" the area is: {area}")

elif op == "circle":

r = input("radius of the circle(must be just a number): ")

r2 = int(r) * 2

area = 3.14 * int(r2)

print(f" the area is: {area}")

Explanation:

this should work to an extent. make sure there's no Intendation or value error.

Answered by atrs7391
11

def square():

   s = float(input("Enter the side of the square: "))

   print("Area of square =", s * s)

def rectangle():

   le = float(input("Enter the length of the rectangle: "))

   b = float(input("Enter the breadth of the rectangle: "))

   print("Area of the rectangle =", le * b)

def circle():

   r = float(input("Enter the radius of the circle: "))

   print("Area of the circle =", 3.14 * (r * r))

print("Press 1 to calculate Area of Square")

print("Press 2 to calculate Area of Rectangle")

print("Press 3 to calculate Area of Circle")

f = int(input())

if f == 1:

   square()

elif f == 2:

   rectangle()

elif f == 3:

   circle()

else:

   print("Error 404: Wrong number pressed, cannot calculate area!")

Similar questions