Calculate Area

 import math


def circle_area(radius):
    return math.pi*radius**2

def square_area(side):
    return side ** 2

def rectangle_area(length, width):
    return length * width

def tringle_area(base, height):
    return 0.5*base*height


def menu():
    print("1.circle : ")
    print("2.square : ")
    print("3.rectangle : ")
    print("4.tringle : ")
    print("5.exit : ")
    print()

While True:
    menu()
    choice= input("Enter Choice : ")

    if choice=='1':
        redius = float(input("Enter the radius of circle : "))
        area = circle_area(radius)

     elif choice=='2':
        redius = float(input("Enter length of side of square : "))
        area = square_area(side)

     elif choice=='3':
        length = float(input("Enter the length  of rectangle : "))
        width =  float(input("Enter the width  of rectangle : "))
        area= rectangle_area(length,width)
        print("the are of rectangle",area)

    elif choice='5':
        print("Existing the program.....")
        break;

    else:
        print("Invalid choice")

print()





Post a Comment

0 Comments