# Accept total number of participants (B) in class. A group offour divisions has to be created from registeredparticipants. The limit

Accept total number of participants (B) in class. A group of four divisions has to be created from registered participants. The limit for registration is 200. If total number of participants registered is even then, criteria for group division are that each group should have equal number of participants. And total number of participants in each group should be an even number.

For example, if P=104 then Group A=26, Group B=26
Group C=26 and Group D=26
If total number of participants is odd number then, criteria for group division is that take the nearest multiple 92 31160 92

Answer: The required code written in python 3 which assigns participants to the 4 groups based on the instruction given goes thus :

def assign(p):
#initialize a function named assign which takes in one argument which is the number of participants
if p%2 == 0 :
#checks if the number of participants is even
val = p/4
#divide the number into 4 equal groups
a,b,c,d = (val,val,val,val)
#assign the equal value to the group ’s using tuple unpacking
print(‘Group A = %d, Group B = %d, Group C = %d, Group D = %d’ %(a,b,c,d))

#display the grouping
else :
#if it is not even, then
val = p//4
#get the whole number divison into 4 groups
rem = p%4
#get the remainder value
a,b,c,d = (val, val, val , val+rem)

#assign the whole number to the first three groups and the sum of the whole number and remainder to the fourth group
print(‘Group A = %d, Group B = %d, Group C = %d, Group D = %d’ %(a,b,c,d))
#display the allocation of participants