from random import random import matplotlib.pyplot as pyplot def attente_succes(p): temps_attente=1 alea=random() while alea>p: alea=random() temps_attente+=1 return temps_attente def simulation(p,N): liste_nbtirages=[0]*30 for i in range(N): t=attente_succes(p) if t<=30: liste_nbtirages[t-1]+=1 pyplot.xlabel("Nombde de tentatives avant le succès") pyplot.ylabel("Effectifs") pyplot.bar(range(1,31),liste_nbtirages,width=0.5,color="blue") pyplot.show()