# Don't rush be quiet - absolutely stumped

I’m completely stumped on this level. It seems like a massive jump up in complexity without a lot of good explanation about what this new mod() function is actually doing. I’m just staring blankly at the screen, then watching as my hero dies in slow motion. Any help much appreciated.

``````def mod30(n):
if n >= 30:
return n - 30
else:
return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def mod40(n):
# Use an if-statement to return the correct value.
if n <= 40:
return n

# You don't need to change the following code:
while True:
time = hero.time
x = mod30(time) + 25
y = mod40(time) + 10
hero.moveXY(x, y)
``````

Hi Chris,

In terms of solving the level, the code for the function for mod40 is nearly identical to the code for function mod30.

You’ve just made me look back at the level, and I don’t think it’s particularly useful for teaching. Apart from anything else, the function doesn’t always calculate the modulus (it works for the numbers being used in the level, but it doesn’t work for bigger numbers).

To get a better understanding of what it’s trying to do, here’s nearly the same code (I changed one word, and then called the function to find the modulus of 278):

``````def mod30(n):
while n >= 30:
n = n - 30
else:
return n

answer = mod30(278)
print(answer)
``````

Copy the code into http://www.pythontutor.com and click ‘Visualise execution’ - you can then go through it step by step.

Cheers,

Jenny

In other words

and

are the same functions

Hi Jenny,

Thanks for another great reply. I just got past the level by tracking down the correct answer from somewhere. I still dont really understand it, even though i understand the concept of modulus and remainders when ive heard it talked about in other places. Hopefully i can understand how the CoCo system uses it better by progressing through.

Thanks again,
Chris

1 Like

Thanks a lot for helping. After taking a week away and coming back to it, and applying everyones ideas i managed to solve the level!
Chris

1 Like
The text passage is a discussion thread about a coding problem involving modulus functions. It includes a code snippet and explanations from users trying to solve the problem.
no_question

the passage does not contain a direct mathematical question or a calculation problem that requires solving. it is a discussion about a coding challenge, but no specific mathematical question is asked or answered.
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
# Don't rush be quiet - absolutely stumped

I’m completely stumped on this level. It seems like a massive jump up in complexity without a lot of good explanation about what this new mod() function is actually doing. I’m just staring blankly at the screen, then watching as my hero dies in slow motion. Any help much appreciated.

``````def mod30(n):
if n >= 30:
return n - 30
else:
return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def mod40(n):
# Use an if-statement to return the correct value.
if n <= 40:
return n

# You don't need to change the following code:
while True:
time = hero.time
x = mod30(time) + 25
y = mod40(time) + 10
hero.moveXY(x, y)
``````

Hi Chris,

In terms of solving the level, the code for the function for mod40 is nearly identical to the code for function mod30.

You’ve just made me look back at the level, and I don’t think it’s particularly useful for teaching. Apart from anything else, the function doesn’t always calculate the modulus (it works for the numbers being used in the level, but it doesn’t work for bigger numbers).

To get a better understanding of what it’s trying to do, here’s nearly the same code (I changed one word, and then called the function to find the modulus of 278):

``````def mod30(n):
while n >= 30:
n = n - 30
else:
return n

answer = mod30(278)
print(answer)
``````

Copy the code into http://www.pythontutor.com and click ‘Visualise execution’ - you can then go through it step by step.

Cheers,

Jenny

In other words

and

are the same functions

Hi Jenny,

Thanks for another great reply. I just got past the level by tracking down the correct answer from somewhere. I still dont really understand it, even though i understand the concept of modulus and remainders when ive heard it talked about in other places. Hopefully i can understand how the CoCo system uses it better by progressing through.

Thanks again,
Chris

1 Like

Thanks a lot for helping. After taking a week away and coming back to it, and applying everyones ideas i managed to solve the level!
Chris

1 Like
user
The text passage is a discussion thread about a coding problem involving modulus functions. It includes a code snippet and explanations from users trying to solve the problem.

TYPE: NO_QUESTION

The passage does not contain a direct mathematical question or a calculation problem that requires solving. It is a discussion about a coding challenge, but no specific mathematical question is asked or answered.