Question: PYTHON Start by creating a new Python file in VSCode named caesar.py.2. Start by writing the main function encrypt_text() that takes two parameters, the plaintext

PYTHON

Start by creating a new Python file in VSCode named caesar.py.2. Start by writing the main function encrypt_text() that takes two parameters, the plaintext andthe shift value (n).3. Inside the function, initialize an empty string ans to store the encrypted message.4. Use a for loop to iterate over the characters of the plaintext.5. Within the for loop, check if the current character is a space (" "). If it is, add a space to the ansstring.6. If the current character is an uppercase letter, use the ord() and chr() functions to encrypt it.Note: The ord() function returns the ASCII value of a character, and the chr() function returnsthe character corresponding to a given ASCII value. To encrypt an uppercase letter, add the shiftvalue to its ASCII value, then use the modulo operator to wrap around the alphabet. Finally,convert the result back to a character using the chr() function and add it to the ans string.Example: ans += chr((ord(ch) + n-65) % 26 + 65)7. If the current character is a lowercase letter, use the same process as above, but this timesubtract 65 and add 97 to ensure that you are working with the correct ASCII range.8. After the for loop has completed, return the ans string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!