(L) contente 1er service
[0.2132 ; 0.2195]
(A) content 1er service
[0.4265 ; 0.4328]
(A) content si (L) contente
[0.4629 ; 0.4692]
(A) pleure si (L) pleure
[0.5781 ; 0.5844]
fromrandomimport*frommathimportsqrt# 4 parts poivrons et 4 parts chorizo
PIZZAS=list('PPPPCCCC')# le cuisinier amene 2 parts
defdeux(parts):# choix d'1 part
p=choice(parts)# on l'enleve de l'ensemble des parts
parts.remove(p)# choix 2e part
v=choice(parts)p+=v# on l'enleve
parts.remove(v)# p est de la forme "PC", "CC" etc.
returnpdefsimul(etat1,etat2,nbSimul=100000):# nb de succes
succes=0n=0# on fait nbSimul simulations
whilen<nbSimul:parts=list(PIZZAS)# 1ere personne servie
p1=deux(parts)# si pas de 2e personne
ifetat2==None:n+=1# si succes ajouter +1
ifp1inetat1:succes+=1# il y a 2e personne et succes pour p1
elifp1inetat1:n+=1# 2e personne servie
p2=deux(parts)# si succes pour p2 (et donc p1), ajouter +1
ifp2inetat2:succes+=1p=succes/nbSimulerr=1/sqrt(nbSimul)print(p-err,p+err)# (L)ouise contente si 2 parts poivrons
print('(L) contente 1er service')simul(['PP'],None)# (A)rthur content si 2 parts identiques
print('(A) content 1er service')simul(['PP','CC'],None)# On sait (L) contente (PP)
# (A) sera content si PP ou CC
print('(A) content si (L) contente')simul(['PP'],['PP','CC'])# On sait (L) pas contente
# elle a donc eu au moins 1 C
# (A) pleurera si parts differentes
print('(A) pleure si (L) pleure')simul(['PC','CP','CC'],['CP','PC'])
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.