Florent Madelaine
84d386a4ae
renommé : exo1.py -> 1/exo1.py renommé : exo2.py -> 1/exo2.py renommé : exo3.py -> 1/exo3.py renommé : exo3b.py -> 1/exo3b.py renommé : first.py -> 1/first.py renommé : loop.py -> 1/loop.py renommé : math0.py -> 1/math0.py renommé : string0.py -> 1/string0.py nouveau fichier : 2Prog.md
39 lines
987 B
Python
39 lines
987 B
Python
# 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()) |