simulation.py

Created by cent20

Created on April 19, 2021

666 Bytes

②nde

Exploité dans le cadre du chapitre 14.


from random import *
from time import *

nb = 42 #^^
print(" " * 27)

def simuler(nb):
    debut = monotonic()
    for i in range(nb):
        resultat = randint(1, 6)
        tirage[resultat] = tirage[resultat] + 1
        tirage[0] = tirage[0] + 1
    return round(monotonic() - debut,4)

while nb != 0:
    print("=" * 30)
    nb = int(input("Combien de lancer : "))
    tirage = [0, 0, 0, 0, 0, 0, 0]
    duree = simuler(nb)
    print("C'était trop facile !")
    print("J'ai fini en ", duree, "secondes")
    for i in range(1, 7):
        print(i, "|", tirage[i], "fois \t |", round(tirage[i] / tirage[0] * 100, 1), "%")
    print(" " * 27)