mardi 28 juillet 2020

computer generating random number

I have been coding with the 'random' library in python3 and generated a random list with the values (0,1), and printed the list. I am not sure if did it wrong or this is the function behavior but with every execution of the program, I could notice that an ordered list with random values has been generated, which could imply that there isn't any randomness? (I know that there isn't really random function, but I wouldn't expect to that kind of order)

    list = []
    for i in range(100):
        if (random.randint(0, 1)) == 1:
            list.append(0)
        else:
            list.append(1)
    for i in range(10):               #
        for j in range(10):           # printing the list
            print(list[j],end=' ')    #
        print('')                     #

print of the list

Any help will be apriciated.

Blockquote




Aucun commentaire:

Enregistrer un commentaire