top of page

Making a Program to find the area of any five shape only use if or else statement


find the area of any five shape only use if or else statement

#Program by eboostup.com
#Making a Program to find the area of any five shape only use if or else statement
print('''
Choose the shape of area you want to solve
1.Square
2.Triangle
3.Rectangle
4.Circle
5.Parallelogram
Hint: Enter only shape name Ex. 'Triangle' ''')
user=str(input("Choose the shape: "))
if user=="Square":
    s=float(input("Side : "))
    area=s*s
    print('Area of Square: %0.2f' %area)
else:
    print()

if user=="Triangle": 
   a = float(input('Enter first side: '))  
   b = float(input('Enter second side: '))  
   c = float(input('Enter third side: '))  
   
   area = (s*(s-a)*(s-b)*(s-c)) ** 0.5  
   print('Area of triangle: %0.2f' %area)   
else:
    print()

if user=="Rectangle":
    l=float(input("Length : "))
    w=float(input("Width : "))
    area=l*w
    print('Area of Rectangle: %0.2f'%area)
else:
    print()

if user=="Circle":
    pi=3.14
    r = float(input('Enter the radius of the circle: '))
    area = pi * r * r
    print('Area of circle: %.2f ' %area)
else:
    print()

if user=="Parallelogram":
   b= float(input('Enter the Base of a parallelogram: '))
   h= float(input('Enter the Height of a parallelogram: '))
   area=b*h  
   print('Area of parallelogram:%.2f'%area)  

if user=="Square" or user=="Triangle" or user=="Rectangle" or user=="Circle" or user=="Parallelogram":
    print()
else:
    print("Invalid Shape")
print("Powered By eboostup")



bottom of page