Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Working on the OPT.2 Cyclic cipher. So far, the tricky part of the exercise is trying to understand the write-up. In step 3, it says "we want the values of the numbers to remain between 0 and 5". Why do we want this? The write-up doesn't explain. I would have thought that digits 0-9 would be wanted. What am I missing here ?

MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
it's a toy example, their example alphabet is 012345, doesn't go as high as 6. They want the numbers to stay within 0-5 in the example. they could have choosen 0123456789, but didn't. replace the "we" by "them", as in them people want....
The modulus operator (%) in X % Y implies number 0 to Y-1. Multiples of Y will result in 0 as the result. For example if Y is 10, whenever X is 10, 20 , 30 or multiples of 10 the % will always result in 0. In other cases it is between 1 to 9. This is explained simply in the course material. 'A' to 'Z' goes from 65 to 91. 'a' to 'z' goes from 97 to 122 in ordinal values. One can calculate modulus separately depending on the values by using either 92 or 123 as Y ... Hope this helps?
This example doesn't relate to the "main" exercise, it's just a way to show how to cycle through an arbitrary number of element in a list. Thus, they use an example with 6 element so you can keep an eye on each of them. For the "main" cipher exercise, you'll have to do the same with 26 elements for lowercase and 26 elements for uppercase.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Thanks to all who clarified this. The exercise is very poorly written. Would have been helpful to reference the symbol alphabet being used and which would be encoded. Something like "Assume that the you will encode any of the 6 symbols "012345" when they occur in the input and that your input sequence is "012345". The initial line of the exercise indicates that it is tricky. I believe it is tricky mostly because it is poorly worded. I'll close out this question in awhile.

Not the answer you are looking for?

Search for more explanations.

Ask your own question