de_grim_magenta.py

Created by niz-moussatat

Created on April 14, 2023

802 Bytes

Simulation d’un dé bleu de Grim


# Type your text here
from random import randint 
def magenta() :  
  face = randint(1,6)
  if face <= 2 :
    return 1
  else :
    return 6 
    
def double_magenta() :  
  face = randint(1,36)
  if face <= 4 :
    return 4
  elif face <= 20 :
    return 7
  else :
    return 12 
    
def frequence_magenta(n) :  
  compteur = 0
  for i in range(n) :
    lancer = magenta()
    if lancer == 1 :
      compteur = compteur + 1
  f = compteur/n
  return f

def frequence_double_magenta(x,n) :  
  compteur = 0
  for i in range(n) :
    lancer = double_magenta()
    if lancer == x :
      compteur = compteur + 1
  f = compteur/n
  return f
  
def moyenne_magenta(n) :  
  cumul = 0
  for i in range(n) :
    cumul = cumul + magenta()
  moyenne = cumul / n
  return moyenne
  
  

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.