21/01/2020, 00:27
21/01/2020, 17:21
21/01/2020, 17:51
22/01/2020, 14:32
22/01/2020, 14:57
22/01/2020, 15:52
22/01/2020, 15:53
import random
def number_of_throws (first_value, second_value):
x = random.randint(1, 6)
counter = first_value
while True:
y = random.randint(1, 6)
counter += 1
if x == first_value and y == second_value:
return counter
x = y
if __name__ == "__main__":
tmp_counter = 0
N = 1000000
for i in range(N):
tmp_counter += number_of_throws(1, 1)
print("Numero di tiri per ottenere sequenza 1-1: ", tmp_counter//N)
tmp_counter = 0
for i in range(N):
tmp_counter += number_of_throws(1, 2)
print("Numero di tiri per ottenere sequenza 1-2: ", tmp_counter//N)
22/01/2020, 19:18
13/02/2020, 14:31
13/02/2020, 14:39
Skuola.net News è una testata giornalistica iscritta al Registro degli Operatori della Comunicazione.
Registrazione: n° 20792 del 23/12/2010.
©2000—
Skuola Network s.r.l. Tutti i diritti riservati. — P.I. 10404470014.
Powered by phpBB © phpBB Group - Privacy policy - Cookie privacy
phpBB Mobile / SEO by Artodia.