mercredi 28 juin 2017

Python, random assgin, attribute

I am writing a program that need to randomly assign the gender attribute (Male/Female) for a list of N objects.

In addition to this, the program also takes another input that is percentage. So, based on the percentage, the program will know how many percent of the N population will be assigned as Female attribute.

For example, I have N = 100 objects, and the percentage = 30% So the output would be 30% arbitrary objects (i.e: 30 objects chosen randomly) of N will be assigned as Female.

Could you help me suggest any algorithm or function, module, package in Python that can do that! Thank you very much




Aucun commentaire:

Enregistrer un commentaire