Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.1 kB
1
Indexable
Never
def what_do_you_want ():
    print ("1: Area of the rectangle")
    print ("2: Square area")
    print ("3: Area of the triangle")
    print ("4: Trapezoidal area")
    print ("5: Area of the circle")
    print ("6: End program")

def area_rectangle_square():
        print ("Enter a value in centimeters")
        a = int(input("side length a:"))
        b = int(input("side length b:"))
        area = a * b
        print("Area is", area, "cm2")

def square_area():
    print ("Enter a value in centimeters")
    a = int(input("side lenght: "))
    square = a * a
    print("Square area is", square, "cm2")

def area_triangle():
        print ("Enter a value in centimeters")
        a = int(input("Enter first side: "))  
        b = int(input("Enter second side: "))  
        c = int(input("Enter third side: "))  
        s = (a + b + c) / 2
        area_triangle = (s*(s-a)*(s-b)*(s-c)) ** 0.5
        print("The area of the triangle is: ", area_triangle, "cm2")

def trapezoidal_area():
        print ("Enter a value in centimeters")
        a = int(input("Base one value: "))  
        b = int(input("Base two value: "))  
        c = int(input("Enter height of trapezoid: "))
        area_trapezoid = ((a + b) / 2) * c
        print("Trapezoidal area is", area_trapezoid, "cm2")

def area_of_circle():
    print ("Enter a value in centimeters")
    a = int(input("Enter the radius of a circle: "))
    PI = 3.14
    area_circle = PI * a * a
    print("Area of the circle is", area_circle, "cm2")
    
        
     
while True:
    what_do_you_want()

    choice = input("What do you want to do? ")
    

    if choice == "1":
        area_rectangle_square()

    elif choice == "2":
        square_area()
        
    elif choice == "3":
        area_triangle()

    elif choice == "4":
        trapezoidal_area()

    elif choice == "5":
        area_of_circle()

    elif choice == "6":
        break

    else:
        print("Incomprehensible choice, try again.")