Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Acrobat Reader File Edit View Window Help ??73% , Sat 9:21 PM a E ?p5.pdf Home Tools p5.pdf Sign In 7596 General Reference: en. Caesar

image text in transcribed

Acrobat Reader File Edit View Window Help ??73% , Sat 9:21 PM a E ?p5.pdf Home Tools p5.pdf Sign In 7596 General Reference: en. Caesar History Caesar used this for his personal corespondence, but it is also a classic cereal box toy for kids. Basic Idea The letters in the alphabet can be "shifted" some umber over For example, with a shift of 1, ab,bcc-d etc, while with a shift of 2 a-c b-dc-e, etc Computers store letters as mmbers, so you can easily "shiff" a letter over to a new symbol by converting the letter to a umber, adding some amount, and changing it back again For example, in ASCII (one of many a number letter mapping for computers). the lower case letter 'a is 97, "b' is 98, etc. In python, the function to get a umber from a letter is called ord) and the function to get a letter from a mumber is called chr(). Below is an example console nun: orda) >chr(97) >> chr(ord'3) 97 Traditionally Caesar shifts wrap around" from z to a (so shifting 2 for "Z results in b").However, with a computer we can allow a little more range, so we'll wrap around if the number is less than 32 (a space) or more than 126 (a). This means that with a shift of 1, an becomes a space, and with a shift of -1 a space becomes a - Note: Wewill alwars cncode a newlinc character as a newline character for Functions get caesar mapping(shift, message) This fiunction accepts a shift amount (positive or negative) and a message and retuns the smallest encoding dictionary needed to encode the message. Remember to wrap as outlined above (you may assume that the shift is in the range of [-94,94]sothat you never have to wrap twice). caesar encode(shift, message: This function accepts a shift amount (positive or negative) and a message and retums the encoded message. Hint: You already know how to do a substirution encoding if yoiu had an encoding dictionary for this shift amount... caesar decode (shift, essage) This function accepts a shift amount (positive or negative) and an encoded nuch to shift it back message and returns the decoded message Note: shift is how much the message was shified, not how 21

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

More Books

Students also viewed these Databases questions

Question

2. Provide recommendations for effective on-the-job training.

Answered: 1 week ago