-
Notifications
You must be signed in to change notification settings - Fork 0
/
volBoite_2.py
35 lines (34 loc) · 958 Bytes
/
volBoite_2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# fonction pour calculer le volume d'une boîte
def volBoite(L,l,p):
if L != 1 and l != 1 and p != 1:
v = L*l*p
v = round(v, 3)
if L != 1 and l == 1 and p == 1:
v = L*L*L
if L == 1 and l != 1 and p == 1:
v = l*l*l
if L == 1 and l == 1 and p != 1:
v = p*p*p
if L != 1 and l != 1 and p == 1:
v = L*L*l
if L == 1 and l != 1 and p != 1:
v = l*l*p
if L != 1 and l == 1 and p != 1:
v = L*L*p
if L == 1 and l == 1 and p == 1:
v = 1
return v
# demande des valeurs, appel fonction puis affichage.
print("----- Calcul du volume d'une boîte ----- \n(Les valeurs nules ou négatives sont transformées\n en 1)\nEntre les trois valeurs :")
Lg = input()
lg = input()
pr = input()
Lg,lg,pr = str(Lg),str(lg),str(pr)
if Lg == "" or Lg <= "0":
Lg = 1
if lg == "" or lg <= "0":
lg = 1
if pr == "" or pr <= "0":
pr = 1
Lg,lg,pr = float(Lg),float(lg),float(pr)
print("Le volume de la boîte est", volBoite(Lg,lg,pr))