publicMasters/python/1/exo3b.py

31 lines
788 B
Python
Raw Normal View History

2022-10-05 17:54:29 +02:00
# Display the following message:
#**************
# 1) Square
# 2) Triangle
# Enter a number :
#**************
# If the user enters 1, then it should ask them for the length of one of its sides and display the area. If they select 2, it should ask for the base and height of the triangle and display the area. If they type in anything else, it should give them a suitable error message.
# square area == side*side
# triangle area == (base*height)/2
print("***************")
print("1) Square")
print("2) Triangle")
print("***************")
v = int(input("Enter a number : "))
if v==1:
square = int(input("coté : "))
area = square*square
elif v==2:
height = int(input("hauteur : "))
base = int(input("base : "))
area = (height*base)/2
print("L'aire est", area)