# Python - Modulo Question

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)
``````

Hi,
yes, as you’ve noticed the team numbers would be 0, 1, 2 and 3. (not 1, 2, 3, 4).
It tends to be quite common to find things in coding that are ‘zero-indexed’ (start counting up from 0, as opposed to 1 ), so don’t be surprised to see it come up again.

Have fun

2 Likes

For this exercise, answer the questions as simply as possible. Get the check mark, first, then stay on the page and play with that sandbox.

it is a simple matter using a bit of logic to create teams numbered 1 thru 4…

``team_num = player_num % 4 or 4``

Thank you very much for the clarification!

Thanks guys for your commets. I was stuck here too and coldn’t undertand the purpose of the exercise. Your conversation really helped me!

1 Like