
Title:
Modulus Quiz Solution  Intro to Computer Science

Description:

Here are the answers. So, for the first question,

we had 12 modulo three and 12 is equal to

three times four. So, that means, if we divide

12 by three we get four with no remainder. So,

that means, the result of 12 modulo three is

zero. For the second question, we could solve this by

figuring out what ord of a is. But we don't

actually need to. We know that the value of ord

for 'a' is always going to be the same every

time we do it. So this is saying, the same value

modular the same value, the result is always going to

be zero. Because anything is divisible by itself with no remainder.

So that answer's also zero. For part C, well now

we've added three. In order to know what the result is

here, we've got to know whether ord of 'z' is greater

than or less than three. As long as ord of z

is greater than three, well that would mean ord of

z plus three modulo ord of z must be three,

because the remainder will be what we added to ord

of z, since ord of z by itself is always divisible

by ord of z. And we do know that ord

of z is greater than threeSo that means the result will

be 3, so let's try that last one in the

Python interpreter. We're going to print the value of ord of z,

plus three, modulo ord of z, and when we run that, we see the result is three,

and I want to point out that the parentheses

here are actually important, if we didn't have them

We tried the order z, plus three order z,

then we get the result 125. And the reason

for that is, the grouping here is going to

group three mod ord z and add that towards ord z,

so it's a different value, and the reason we get 125 is the value

of ord z by it's self. Is 122. So it's 122, which is ord

of z, plus three mod ord of z, which is three mod 122, which is

three, which is why we got 125 when we evaluated this without the parentheses.