I am doing the “Learn Python 3” course and I have a question regarding the Modulo section. Our instructions are as follows:
1.
You’re trying to divide a group into four teams. All of you count off, and you get number 27.
Find out your team by computing 27 modulo 4. Save the value to my_team
.
2.
Print out my_team
. What number team are you on?
3.
Food for thought: what number team are the two people next to you (26 and 28) on? What are the numbers for all 4 teams? (Optional Challenge Question)
I understand that in order to get the number team that person 26 and 28 are, we must do it on modulo form.
number_26 = (26 % 4)
number_28 = (28 % 4)
However, there are 4 teams: 1, 2, 3, and 4. When you run the code of number_28 = (28 % 4) you are left with 0 because 28 is divisible by 4 without having a remainder. In a practical situation, how would this work? Team 0 doesn’t technically exist, right?
Edit: Just adding the code and noticed that really, anybody that belongs in “Team 4” is technically assigned “Team 0” if done with modulo.
# Total of 27 people divided into 4 different teams
my_team = (27 % 4)
print ('My Team')
print (my_team)
# Bonus question
number_26 = (26 % 4)
number_28 = (28 % 4)
print ('Number 26')
print (number_26)
print ('Number 28')
print (number_28)