Accept Total Number of Participants in Class Program in Python For TCS

Accept Total Number of Participants in Class Program in Python For TCS

Accept total number of participants (P) in class. A group of four divisions has to be created from registered participants. The 200. Sen hit for registration is of total number of participants registered is even number 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, hereof 4 less than P and perform four equal for group division is that take the nearest divisions and then the left out participants are added in Group ā€˜Dā€™. For example, If P=127, then Group A=31, Group B=31 Group C=31 and Group D=34 Group D is 34 because 31 participants plus left out 3 participants are added in this group Display report on total number of participants in each group.

Input: 104

output:

Participants of Group A: 26

Participants of Group B: 26

Participants of Group C: 26

Participants of Group D: 26

Input:127

Output:

Participants of Group A: 31

Participants of Group B: 31

Participants of Group C: 31

Participants of Group D: 34

Solution in Python

p = int(input('Enter the number of participants :'))

if (p<100 or p>200):

  print('INVALID INPUT')

else:

 a = int(p/4)

 if(p%2==0):

  print('Participants in Group A :',a)

  print('Participants in Group B :',a)

  print('Participants in Group C :',a)

  print('Participants in Group D :',a)

 else:

   b = p%4

   print('Participants in Group A :',a)

   print('Participants in Group B :',a)

   print('Participants in Group C :',a)

   print('Participants in Group D :',a+b)

Additional Reading

you can read more articles like this here.

READ MORE

Dheeraj Pal:

This website uses cookies.