Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Go to https://en.wikipedia.org/wiki/Caesar_cipher to see what a Caesar cipher is. Write a function called cipher(phrase,shift) that accepts two parameters: a string phrase and an

1) Go to https://en.wikipedia.org/wiki/Caesar_cipher to see what a Caesar cipher is. 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 http://www.asciitable.com/. 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)image text in transcribed

Caseripher - Cara makwychwojecte Casarphat) --py - PyCharm Edu 30 File Ede Yew ge Code Help Project . 0 0 . lpy Caesar Cipher C osmo Caesar cipher http//en.wikipedia.org/wiki/Caesar opher a mal Libraries ASCII ble het . bu. F i from the character to the character Rotate about the character in the man R de chishshafe printeipher (" A E ", 97 - 65) printeipherede, 65 -97) print Icipher ( 5,0)) printeipher2 .95) printeipher(125", -95 print (espher(125",2)) print loipher 18, 2+951) printeipher :",-3) print loipher ( 28.-3-95) print loipher("Attack at printeipher a print topher (Attack at postephe n aw", 13)) .-13) ", 134952) ".-13-95-2)) print(cipher ("These are a pair of ().- 209543) print Icipher("hly tyla'you 44028", -20-954) lytys Run Python Console IAL CRLF: UTF-4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions