from random import * def simulation1(): tirage = randint(1, 10) if tirage <= 3: return 1 else: return 0
from random import *
def simulation2(n):
echantillon = []
for i in range(n):
tirage = randint(1, 10)
if tirage ... :
echantillon.append(1)
else:
echantillon.append(0)
return echantillon
from random import *
def simulation2(n):
echantillon = []
for i in range(1, n):
tirage = randint(1, 10)
if tirage ... :
echantillon.append(1)
else:
echantillon.append(0)
return echantillon
def simulation3(n):
L = []
for i in range(100):
L1 = simulation2(n)
L.append(L1)
return L
from random import random
def genereechantillon(n,p):
echantillon = []
for i in range(n):
tirage = random()
if tirage <= p:
echantillon.append(1)
else :
echantillon.append(0)
return echantillon
ech = genereechantillon(100,0.3)
total = 0
for j in range(100):
total = total + ech[j]
moyenne = total/100
print(moyenne)
Nos manuels sont collaboratifs, n'hésitez pas à nous en faire part.
j'ai une idée !
Oups, une coquille