Just for a reminder, the only question we are expected to answer is what team number is player number 27 on? Simple question, simple answer.
Since 27%4 = 3 it means I’m on Team 3. 1 out of 4 teams are already taken, so that leaves 3 teams for 26 and 28.
print(my_team) #team 3
print(my_team) #team 2
print(my_team) #team 1
This is really late but I hope it helps
Thanks this is really helpful!
1 % 27
and got 1
I got it right, but i’m a bit confused about how everyone could have 1 as their team number please can somebody elaborate as to how this answer worked.
Hello, @jasd1146130261. Welcome to the forums.
Not sure why you did 1 % 27, but the
% operator returns the remainder after dividing the second parameter into the first. What is 1 divided by 27? 0 with a remainder of 1. What is 1 divided by any number other than 1 or -1 or 0 (not legal)? The answer is 0 with a remainder of 1.
>>> 1 % 0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: integer division or modulo by zero >>> 1 % -1 0 >>> 1 % 1 0 >>> 1 % 6 1 >>> 1 % 52 1 >>> 1 % 941 1 >>> 1 % 9999999999999999 1
Codecademy need to be more clearer than this. Start of the coure and question is not clear or word nicley. Not catering for new to python or math and no solution in the solution section =
my_team = 27 % 4
teams26 = 26 % 4;
teams28 = 28 % 4;
Is there a specific question you have?
It is definitely poorly worded for a beginning Python tutorial, with no immediate pointers to a strategy or an explanation of “for loops” and the “range()” function. But this is what I came up with…
for team in range(1,5): print("Team " + str(team) + ":") for num in range(team, 29 ,4): print(num)
It first iterates through a team number and prints it (the variable “team”) which also gives it a starting point for further iteration, given that the team is counted out 1 - 4 repeating in this model. Then it counts out each team member, 1 - 4, from the starting point (the variable “team”, all the way through 28)
Weirdly enough question #3 this does not require modulo as suggested. Although I’m sure there’s likely a way to implement it that I’m missing.
I guess I don’t exactly understand what a Modulo is. Is it actually finding a percentage? I don’t see how it could be a remainder of division in this question.
Not a percentage, no. It really is a remainder of division as the name of the operator suggests: remainder operator.
27 / 4 == 6-3/4 4 * 3/4 == 3 27 % 4 == 3
Thanks! It took me a minute but I think I understand a little better now. That question threw me off with the way it was worded