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)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

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.