## ← Modulus Quiz Solution - Intro to Computer Science

• 3 Followers
• 35 Lines

### Get Embed Code x Embed video Use the following code to embed this video. See our usage guide for more details on embedding. Paste this in your document somewhere (closest to the closing body tag is preferable): ```<script type="text/javascript" src='https://amara.org/embedder-iframe'></script> ``` Paste this inside your HTML body, where you want to include the widget: ```<div class="amara-embed" data-url="http://www.youtube.com/watch?v=nmV96-OcGi4" data-team="udacity"></div> ``` 2 Languages

Showing Revision 6 created 07/06/2017 by Dejan Trajkovic.

1. Here are the answers. So, for the first question,
2. we had 12 modulo three and 12 is equal to
3. three times four. So, that means, if we divide
4. 12 by three we get four with no remainder. So,
5. that means, the result of 12 modulo three is
6. zero. For the second question, we could solve this by
7. figuring out what ord of a is. But we don't
8. actually need to. We know that the value of ord
9. for 'a' is always going to be the same every
10. time we do it. So this is saying, the same value
11. modular the same value, the result is always going to
12. be zero. Because anything is divisible by itself with no remainder.
13. So that answer's also zero. For part C, well now
14. we've added three. In order to know what the result is
15. here, we've got to know whether ord of 'z' is greater
16. than or less than three. As long as ord of z
17. is greater than three, well that would mean ord of
18. z plus three modulo ord of z must be three,
19. because the remainder will be what we added to ord
20. of z, since ord of z by itself is always divisible
21. by ord of z. And we do know that ord
22. of z is greater than threeSo that means the result will
23. be 3, so let's try that last one in the
24. Python interpreter. We're going to print the value of ord of z,
25. plus three, modulo ord of z, and when we run that, we see the result is three,
26. and I want to point out that the parentheses
27. here are actually important, if we didn't have them
28. We tried the order z, plus three order z,
29. then we get the result 125. And the reason
30. for that is, the grouping here is going to
31. group three mod ord z and add that towards ord z,
32. so it's a different value, and the reason we get 125 is the value
33. of ord z by it's self. Is 122. So it's 122, which is ord
34. of z, plus three mod ord of z, which is three mod 122, which is
35. three, which is why we got 125 when we evaluated this without the parentheses.