Question: Write a function called cipher(phrase,shift) that accepts two parameters: a string phrase and an integer shift. The integer shift can be positive, negative or zero.
Write a function called cipher(phrase,shift) that accepts two parameters: a string phrase and an integer shift. The integer shift can be positive, negative or zero. Mentally form a ring of characters made up of the character space (ascii code 32) through the character ~ (ascii code 126) in the ASCII table. Shift the characters in the phrase specified by the number shift. If it is positive, shift the phrase to the right, or up. If it is negative, shift the phrase to the left, or down. Your function should be able to wrap around as well. Hence, cipher(~,1) will yield and cipher( ,-2) will yield }. Hint: there are 95 characters in the ring. That is, 95 = ord('~') - ord(' ') + 1. You may want to use the following functions in your code: ord(A) = 65, and chr(65) = A, and .join([A,B]) = AB. (200 points)
** Please do in Python!! I need the black scribbled parts and please provide a screenshot/explanation... Please match the output exactly. I need line 38 & 40 to match once outputted that is mainly what I am struggling with.


3 Project 3 * 1.py X Caesar Cipher C:\Users\mokwip 1 Caesar cipher https://en.vikipedia.org/wiki/Caesar_cipher | External Libraries 2 # ASCII Table http://www.asciitable.com/ # Form a ring from the character to the character ''. 4 * Rotate about the characters in this ring. 5 def cipher (phrase, shift): 7 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 print (cipher ("ABCDE", 97 - 65)) print (cipher ("abode", 65 - 97)) print (cipher(" !"#$",0)) print (cipher(" !"#$",95)) print (cipher (" !\"#$", -95)) 31 32 33 34 print (cipher(" !"#$", 2)) print (cipher(" !"#$", 2-95)) print (cipher(" !"#$", -3)) print (cipher(" !"#$",-3-95)) 35 36 37 38 39 print (cipher ("Attack at dawn", 13)) print (cipher ("N\"\"npx-n\"-q*{", -13)) print (cipher ("Attack at dawn", 13+95.2)) print (cipher ("N\"\"npx-n\"-qn8", -13-95*2)) 41 42 print (cipher ("These are a pair of {}.", 20+95-3)) print (cipher ("hly (y4u'y4u48u}'4$2402B", -20-95*4)) Run 1 abcde ABCDE !"#$ !"#$ A = 80 x *$35 "#666 1)-! N""npx-n"-en ! Attack at dawn N""npx-n"-ant Attack at dawn hly(y4u'y4u4u) '442402B These are a pair of {}. Process finished with exit code 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
