Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1(23 + 5) MOD 26 | ADecrypts C with a shift of 5 by moving back 5 places, wrapping round to position 23, which is X | |
| 2(2 - 5 + 26) MOD 26 | BnewPos = (pos - shift + 26) MOD 26 | |
| 3To encrypt, add the shift to the letter's position, then use MOD 26 so the result stays between 0 and 25 | CThe alphabet has 26 letters, so the wrap must use MOD 26, not MOD 25. With MOD 25, Z (25) would wrongly wrap to 0 and letters would be miscalculated. | |
| 4To decrypt with a negative shift, subtract the shift, add 26 so it is not negative, then wrap with MOD 26 | DThere is no MOD 26, so X (23) shifted by 5 gives 28, which is not a letter. The result never wraps back to the start of the alphabet. | |
| 5newPos = (pos + shift) MOD 25 | EnewPos = (pos + shift) MOD 26 | |
| 6newPos = pos + shift | FEncrypts X with a shift of 5: 28 wraps around to 2, which is the letter C |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
(position + shift) MOD 26 — Caesar wrap-around rule: with A=0 to Z=25, add the shift then take MOD 26 so letters past Z loop back to A. Example: X (23) + 5 = 28, MOD 26 = 2, which is C.(23 + 5) MOD 26 = 2(23 + 5) MOD 26 = 2newPos = (pos + shift) MOD 26=MOD(2+-5,26)X = 23
23 + 5 = 28
28 MOD 26 = 2