Advertisement
philRG

mon ami Jé :-)

Apr 12th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. tic = time.time()
  5. profondeur = 100000
  6.  
  7. t = ['bourreau', 'partenaire', 'ami']
  8.  
  9. c = {i: 0 for i in range(len(t))}
  10.  
  11. i = 0
  12.  
  13. while i < profondeur:
  14.     a = random.choice(t)
  15.     j = t.index(a)
  16.     c[j] += 1
  17.     i += 1
  18.  
  19.  
  20. d = {t[i]: f'{round(100 * c[i] / sum(c.values()), 2)}%' for i in range(len(t))}
  21.  
  22.  
  23. print(f'Résultat {profondeur} itérations en {round((time.time() - tic) * 1000)} ms: {d}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement