mercredi 6 novembre 2019

how to calculate the frequency of the random numbers

i would like to generate random numbers for 5 minutes. after that, i would like to calculate the most common numbers.

for example i generate following numbers: 1:2578 2:3456 3:2578 4:9999 5:2578

i want to find the most common numbers which are 2578.

following is my code. I would like to generate random numbers for 5 minutes. And find which one is the most common one. however, i am trying to find the most common numbers.can someone enlighten me?

import random
while True:
    number=[random.randint(0,9)for value in range(0,4)]
    print(f"{number[0]}{number[1]}{number[2]}{number[3]}")



Aucun commentaire:

Enregistrer un commentaire