lundi 25 novembre 2019

Python: Random but equally distributed

I want to code a test unit in Django/Python and I need to create a table with one column filled with 'random' integer choosen (1,2,3,4) and equally distributed

this table contain 64 rows and I should have:

  • 16 rows filled with '1'
  • 16 rows filled with '2'
  • 16 rows filled with '3'
  • 16 rows filled with '4'

I try with randint but it is not equally distributed I read about uniform but it return a float

for i in (range(1,65)):
    r = uniform(1,4)



Aucun commentaire:

Enregistrer un commentaire