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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| #!/usr/bin/python3.1
# -*-coding:Utf-8 -*
import numpy as np
import matplotlib.pyplot as plt
#dessiner les courbes
t = np.linspace (1.50,2.10,10) #10 étant le nombre de points de passage
imc1 = (16*(t**2)) # il faut démarrer l'opération depuis la valeur de l'IMC
plt.plot (t,imc1, label="anorexie") #ne pas oublier plt.legend()
plt.legend()
t = np.linspace (1.50,2.10,10)
imc2= (18.5*(t**2))
plt.plot (t,imc2,label="maigreur")
plt.legend()
t = np.linspace (1.50,2.10,10)
imc3= (30*(t**2))
plt.plot (t,imc3, label="corpulence normale")
plt.legend()
t = np.linspace (1.50,2.10,10)
imc4= (35*(t**2))
plt.plot (t,imc4,label="surpoids")
plt.legend()
t = np.linspace (1.50,2.10,10)
imc5= (40*(t**2))
plt.plot (t,imc5,label="obésité modéré")
plt.legend()
t = np.linspace (1.50,2.10,10)
imc6= (60*(t**2))
plt.plot (t,imc6, label="obésité élevée")
plt.legend()
# cadre et légende
plt.title("Courbes IMC")#fonctionne si avant plt.show()
plt.xlabel('taille en mètres')
plt.ylabel('poids en kg')
plt.xlim(1.50, 2.10)
plt.ylim(40, 200)
#calcul de l'imc de l'utilisateur
print ('entre ton poids : ',)
p = float(input())
print ('entre maintenant ta taille en mètre: ' ,) #du type 1.59 et non 159
t = float(input())
imc = float(p/(t**2)) # l'IMC de la personne
print('ton IMC est de ', imc ) #pas besoin de remettre l'opération
# dessiner la courbe d'IMC de l'utilisateur
#récupérer la valeur de son imc :c'est fait ligne 56
plt.plot (t,imc, "b:o", label="ta courbe", linewidth=4)
plt.legend()
plt.show() |