renommé : entier.py -> 1/entier.py

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
This commit is contained in:
2022-10-13 21:51:40 +02:00
parent 02afd53f1b
commit 84d386a4ae
10 changed files with 0 additions and 0 deletions

39
python/1/exo3.py Normal file
View File

@@ -0,0 +1,39 @@
# 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())