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 | |
|---|---|---|
| 1key = '31415' | APicks the key digit for position i, repeating the key along a longer message | |
| 2key[i % len(key)] | B(n - shift) % 26 | |
| 3To encrypt, shift the letter number forward by its key digit and wrap round with MOD 26 | CThe same digit 3 was used for both letters. The key moves to the next digit, so I is shifted by 1 and becomes J. The correct result is KJ. | |
| 4To decrypt, shift the letter number backward by the same key digit and wrap with MOD 26 | D(n + shift) % 26 | |
| 5key = '3A415' | EA Gronsfeld key: a string of digits 0-9 where each digit is the shift for one letter | |
| 6HI with key 31 gives KK | FA Gronsfeld key can only use digits 0-9. The letter A makes this a Vigenere-style key and gives no valid numeric shift. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Gronsfeld cipher — A Vigenere variant whose key is a string of digits 0-9, like 31415. Each digit is the shift for one letter, and the key repeats along the message.shift = int(key[i % len(key)])shift = int(key[i % len(key)])new = (ord(ch) - 65 + shift) % 26 + 65new = (ord(ch) - 65 - shift) % 26 + 65shifts = list(range(0, 10))