jeudi 20 mai 2021

Is this just very unlikely? Or is it impossible

So, I'm a beginner in python (coding in general, really), and I've tried to make this little program which generates a random number of rods in 305 attempts

import random
rods = 0
def blazerods():
    global rods
    seed = random.randint(0, 100000000000)
    random.seed(seed)
    i = 0
    rods = 0
    for i in range(0, 305):
        rnd = random.random()
        if rnd < 0.50:
            rods += 1
    print(rods)
    return rods


while 1==1:
    blazerods()
    if rods >= 211:
        break

The goal is to get 211 or more rods. However, I ran the program for 30 minutes without results.

My questions are: Is it even possible to get 211 or higher with just this code I included?

Can I make it more likely that rods can be more than 211 (still being a very unlikely result, ofc) without changing the chance(50%)?

Is random.seed(seed) even useful?




Aucun commentaire:

Enregistrer un commentaire