If and elif

PHOTO EMBED

Wed Feb 02 2022 00:24:36 GMT+0000 (Coordinated Universal Time)

Saved by @aymenben99

figura = "triangle"
if figura == "circle":
    radio= int(input("Enter the radius of the circle:"))
    pi=3.14
    area = pi*(radio**2)
    print("The area of the circle""is: ",area)
    
elif figura == "square":
    lado = int(input("Enter the length of the side:"))
    area = lado*lado
    print("The area of the square with side",lado,"is: ",area)
    
elif figura == "triangle":
    altura = int(input("Enter the height of the triangle:"))
    base = int(input("Enter the base of the triangle:"))
    area = (base*altura)/2
    print("The area of the triangle with height",altura,"and base ",base,    "is: ",area)
    
elif figura == "rectangle":
    altura = int(input("Enter the height of the rectangle:"))
    base = int(input("Enter the base of the rectangle:"))
    area = base*altura
    print("The area of the rectangle with height",altura,"and base",base,   "is: ",area)
else:
    print("failure")
content_copyCOPY