ch11_ex93_prof.py

Created by manuel-2de-indice2019

Created on October 14, 2019

655 Bytes


from random import*
def souris():
    s=1
    while s!=3 and s!=5:
        if s==1:
            a=randint(0,1)
            if a==0:
                s=4
            else :
                s=2
        if s==2 :
            a=randint(0,1)
            if a==0:
                s=3
            else :
                s=1
        if s==4 :
            a2=randint(0,2)
            if a2==0:
                s=1
            if a2==1:
                s=3
            if a2==2:
                s=5
    if s==3:
        return 0
    else :
        return 1

def rep_souris(N):
    n=0
    for k in range(N):
        n=n+souris()
    return(n/N)