Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 Part 1: Consider the string made up of the uppercase letters of the alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ Write a Python program that circularly shifts the
Question 3 Part 1: Consider the string made up of the uppercase letters of the alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ Write a Python program that circularly shifts the characters of the above string by n positions to the left. The number n should be a command line argument. Your program should be run like so: python cshift.py 3 The integer argument is the number n. You may assume that n is greater than or equal to zero. A circular shift to the left rotates the letters of the string n positions to the left. Shifting by n = 26 positions is equivalent to shifting by n = 0 positions, shifting by n = 27 positions is equivalent to shifting by n=1 positions, shifting by n = 28 positions is equivalent to shifting by n = 2 positions, and so on. Your program should print the circularly shifted string; for example: python cshift.py O ABCDEFGHIJKLMNOPQRSTUVWXYZ python cshift.py 1 BCDEFGHIJKLMNOPQRSTUVWXYZA python cshift.py 2 CDEFGHIJKLMNOPQRSTUVWXYZAB python cshift.py 3 DEFGHIJKLMNOPQRSTUVWXYZABC python cshift.py 25 ZABCDEFGHIJKLMNOPQRSTUVWXY python cshift.py 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ python cshift.py 53 BCDEFGHIJKLMNOPQRSTUVWXYZA Part 2: A Caesar cipher is a simple method for encrypting a text message. First, create a cipher alphabet by circularly shifting the letters of the alphabet by n positions to the left. For example, the cipher alphabet obtained by shifting 3 positions to the left is: DEFGHIJKLMNOPQRSTUVWXYZABC To encrypt a message, replace each letter of the message with the corresponding letter in the cipher alphabet. The above cipher alphabet and the original alphabet are shown below: DEFGHIJKLMNOPQRSTUVWXYZABC ABCDEFGHIJKLMNOPQRSTUVWXYZ cipher alphabet original alphabet Encrypting a string results in the following cipher text: WE HAVE NO BANANAS ZH KDYH OR EDQDQDV original message cipher text For our purposes, characters not in the alphabet are not transformed (so that spaces or punctuation in the original message appear in the same location in the cipher text). Write a Python program that encrypts a message using an n-shift Caesar cipher. Your program should be run like so: Mac and Linux users python encrypt.py 3 'WE HAVE NO BANANAS Windows users python encrypt.py 3 "WE HAVE NO BANANAS" The integer argument is the number n. The second argument is the message to be encrypted (enclosing the second argument in quotes causes the terminal to treat everything inside the quotes as one argument). Your program should print the cipher text; for example: python encrypt.py i 'ABC' BCD python encrypt.py 12 'HELLO TOXXA python encrypt.py 25 '1, 2, 3, 4 TELL ME THAT YOU LOVE ME MORE 1, 2, 3, 4 SDKK LD SGZS XNT KNUD LD LNQD
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started