publicMasters/python/1/exo3.py

39 lines
987 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
for i in range(0,15):
print('*', end='')
print("\n1) Square")
print("2) Triangle")
for i in range(0,15):
print('*', end='')
v = int(input("\n\nEnter a number : "))
if v==1:
side = int(input("Enter a side : "))
area = side*side
elif v==2:
height = int(input("Enter a height : "))
base = int(input("Enter a base: "))
area = (height*base)/2
else:
print("Input error (waiting for 1 or 2)!!!!!")
if v==1:
print("The area of the square is", area)
elif v==2:
print("The area of the triangle is", area)
print("toto".title())