Question: Hi I need help in this python assignment please 1. Defining functioncipher(plaintext, n)to shift all characters in a string of text. Your function should take
Hi I need help in this python assignment please
1. Defining functioncipher(plaintext, n)to shift all characters in a string of text. Your function should take 2 parameters, theplaintextto shift (a string) and the shift keyn(an integer). Set up an accumulator variable (suggested name:ciphertext) in which to accumulate the result. Use a definite loop with the accumulator pattern to go through all characters in plaintext.
For each character, call yourshift_charfunction to obtain the shifted version of that character, which you will concatenate into ciphertext. Return theciphertextafter the loop.
Here are some test cases:
>>> cipher('time', 4) 'xmqi' >>> cipher('welcome to the machine', 19) 'pxevhfx mh max ftvabgx'
2.Suppose you have someciphertext(i.e.,'iuet kag iqdq tqdq', or'prqhb') but you don't know which decryption key (i.e., the number of characters to shift) to use. define function calledcodebreaker(ciphertext)that will try all possible Caesar cipher shifts (there are only 26 to try) and print out each possible deciphering. One of them will stand out as a valid English phrase. Your program must re-use yourcipherfunction from question 2 above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
