This is one full question. Please write in Python.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

This is one full question. Please write in Python.

Post by answerhappygod »

This is one full question. Please write in Python.
This Is One Full Question Please Write In Python 1
This Is One Full Question Please Write In Python 1 (652.31 KiB) Viewed 35 times
The resulting ciphertext is TLRUHCPO. The recipient can follow the same steps as above – but shifting backwards each time to recover the plaintext. Within ciphers.py, write a function fancy-caesar(input_text, keyword, do_encrypt) that returns the result of applying the variable-shift Caesar cipher described previously to the input_text, using the specified keyword. You may assume that both input_text and keyword are non-empty. This function should handle both encryption and decryption. If the parameter do_encrypt is True, the function should perform encryption (i.e., shifting input_text forward in the alphabet). If do_encrypt is False, the function should perform decryption (i.e., shifting input_text backward in the alphabet). Be sure to account for cases of shifting past A and Z. Clean up both the input_text and keyword parameters by calling your previously written cleanup-text() function before proceeding. Do not call any built-in Python functions except chr(), len(), ord(), and range () in your solution. Here are some example arguments for this function and their expected return values: 7 1 Return Value 'SLOTH' 'SLOTH' 'W' 7 7 7 Arguments ('sloth', 'a', True) ('sloth', 'a', False) ('a', 'weird', True) ('W', 'weird', False) ('sloth', 'ABCDE', True) (“smqul', 'abcde', False) (ʻzebras are mediocre!', 'lemon', True) (“Kin. .FnDEDS, . ZPh!!9234UCPCI', lEmoN', False) A' > 7 'SMQWL' SLOTH' 'KINENDEDSZPHUCPCI' ZEBRASAREMEDIOCRE' 7

3. (12 points) In the Caesar cipher, encryption is done by shifting each letter in the plaintext forward in the alphabet by a certain amount. Going past Z wraps back around to A. For example, to encrypt the message SLOTH 200 with a shift of 2, A in the plaintext is replaced by C, B in the plaintext is replaced by D, and so on. This results in a ciphertext of UNQVJBQQİ The message recipient can recover the plaintext by applying the same shift in reverse. We can make the Caesar cipher more sophisticated by varying the amount of shifting for each letter of the plaintext. This can be done by using a keyword instead of a single shift amount. The letters of the keyword determine the shift amount, with A being 0 (no shift), B being 1, C being 2, and so on. The letters of the keyword are used from beginning to end, wrapping around as many times as needed. For example, to encrypt the message SLOTH 200 with a keyword of BAD: • Shift S forward by 1 (from B in the keyword) to obtain T. • Shift L forward by 0 (from A in the keyword) to obtain L. • Shift O forward by 3 (from D in the keyword) to obtain R. • Shift T forward by 1 (from B in the keyword) to obtain U. • Shift H forward by 0 (from A in the keyword) to obtain H. • Omit the space. • Shift Z forward by 3 (from D in the keyword) to obtain C. • Shift O forward by 1 (from B in the keyword) to obtain P. • Shift O forward by 0 (from A in the keyword) to obtain 0.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply