Check your understanding of the previous reading: rotating characters and strings with the rotation formula.
Rotate all of the following characters by the given amount, to determine a new character. Do not put quotes around the resulting character.
A by 1:
A is 65: (65 + 1 - 32) % 94 + 32 is 66, and chr(66) is B.
A by 2:
A is 65: (65 + 2 - 32) % 94 + 32 is 67, and chr(67) is C.
A by 10:
A is 65: (65 + 10 - 32) % 94 + 32 is 75, and chr(75) is K.
A by -1:
A is 65: (65 - 1 - 32) % 94 + 32 is 64, and chr(64) is @. Rotating backwards from A gives the character just before it.
B by 2:
B is 66: (66 + 2 - 32) % 94 + 32 is 68, and chr(68) is D.
B by 25:
B is 66: (66 + 25 - 32) % 94 + 32 is 91, and chr(91) is [. 91 is the character right after Z (90).
= by -1:
= is 61: (61 - 1 - 32) % 94 + 32 is 60, and chr(60) is <.
a by 1:
a is 97: (97 + 1 - 32) % 94 + 32 is 98, and chr(98) is b.
z by 5:
z is 122: (122 + 5 - 32) % 94 + 32 is 33, and chr(33) is !. 122 + 5 - 32 is 95, past the end of the wheel, so the modulo wraps it around to 1: the wheel starts again at the space (32).
z by 8:
z is 122: (122 + 8 - 32) % 94 + 32 is 36, and chr(36) is $. The modulo wraps the wheel around past ~, back to the start.
2 by -30:
2 is 50: (50 - 30 - 32) % 94 + 32 is 114, and chr(114) is r. 50 - 30 - 32 is -12, and in Python -12 % 94 is 82 (the result of % is never negative here), so the result is 82 + 32.
What is the result of rotating the string Dragons! by 10? Do not put quotation marks around your answer, just enter the characters.
Rotate every character by 10: D (68) becomes 78, N, r (114) becomes 124, |, a (97) becomes 107, k, g (103) becomes 113, q, o (111) becomes 121, y, n (110) becomes 120, x, s (115) becomes 125, }, ! (33) becomes 43, +. No code goes past the end of the wheel, so nothing wraps around. Rotating adds no tildes: that is a separate step of encrypt_text.