#!/bin/python3 # Simulacion numerica del problema 1c de la guia 2. (FT3 2Cuat 2018) from random import seed from random import randint # seed random number generator seed() n_exp = 180000 # number of experiments n_fav = 0 # number of favorable cases for i_exp in range(n_exp): urna_A=["b","b","b","b","b","b","b","n","n","n"] urna_B=["b","b","b","b","b","n","n","n","n","n"] # Select ball from A nro_bola_A = randint(0, len(urna_A) - 1) # raffle which ball do I take from A bola_extraida_A = urna_A[nro_bola_A] # Select that ball from A #Meto bola extraida en urna A en urna B urna_B.append( bola_extraida_A ) #Select ball from B nro_bola_B = randint(0, len(urna_B) - 1) # raffle which ball do I take from B bola_extraida_B = urna_B[nro_bola_B] if bola_extraida_B == "n" and bola_extraida_A == "n": n_fav += 1 print( float(n_fav) / float(n_exp) )