{}
Build with AI. Win prizes. Get featured on the Wall.
Join Challenge
Build with AI. Win prizes. Get featured on the Wall. Join Challenge
run-icon
main.py
print("----------------------------------- Welcome to Area Calculator ------------------------------------ \n") shape = None try: shape = int(input("Please Select Shape (Enter Number to Select): \n [1] Square [2] Rectangle [3] Triangle [4] Circle \n=> ")) except: print("Invalid Input, Use Numbers to Select Shape") shape = None if shape: if shape == 1: try: side = int(input('Enter side Length (in meters): ')) print("Area of Square:", side * side, "sq. m.") except: print("Invalid Input, Length can be in numbers only") elif shape == 2: try: side1 = int(input('Enter Length of Rectangle (in meters): ')) side2 = int(input('Enter Breadth of Rectangle (in meters): ')) print("Area of Rectangle:", side1 * side2, "sq. m.") except: print("Invalid Input, Length can be in numbers only") elif shape == 3: try: base = int(input('Enter Length of Base of Triangle (in meters): ')) height = int(input('Enter Height of Triangle (in meters): ')) print("Area of Triangle:", (base * height) / 2, "sq. m.") except: print("Invalid Input, Length can be in numbers only") elif shape == 4: try: PI = 3.14; radius = int(input('Enter Radius of Circle (in meters): ')) print("Area of Circle:", PI*radius*radius, "sq. m.") except: print("Invalid Input, Length can be in numbers only") else: print('Invalid Input! Choose from 1,2,3,4')
Output