In: Computer Science
In Python...
Write a program that randomly assign participants for a study (use the random module).
The program should:
Remember:
# Code import random print("Program that randomly assign participants for a study (use the random module).") n = int(input("Enter number of participants in the study: ")) minAge = int(input("Enter minimum age of the participants: ")) maxAge = int(input("Enter maximum age of the participants: ")) gender = [] age = [] for i in range(n): gender.append(random.randint(1,2)) age.append(random.randint(minAge,maxAge)) maleCount = 0 femaleCount = 0 sumMaleAge = 0 sumFemaleAge = 0 for i in range(n): if(gender[i]==1): maleCount += 1 sumMaleAge += age[i] else: femaleCount += 1 sumFemaleAge += age[i] print("Total number of male participants =",maleCount) print("Male participants average age =",(sumMaleAge/maleCount)) print("Total number of female participants =",femaleCount) print("Female participants average age =",(sumFemaleAge/femaleCount))