Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a script that inputs a line of plaintext and a distance value and outputs

ID: 3889672 • Letter: W

Question

Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher. The script should work for any printable characters.

Here are what the expexted results are supposed to be. This is an activity from MindTap. Thank you

MINDTAP From Cengage Strings and Text Files (Exercise 1) Due on Sep 26 at 11:59 PM EDT encrypt.py 1# Prompt user to enter a message Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher. The script should work for any printable characters 3# Prompt user to enter a shift 4 | 5 # Print the encrypted message

Explanation / Answer

def caesar(plainText, shift):
cipherText = ""
for char in plainText:
    newChar = ord(char) + shift
    if newChar > 128:
      newChar = newChar % 128
    finalChar = chr(newChar)
    cipherText += finalChar
return cipherText

text = input("Enter plain text: ");
s = input("Shift: ");
print (caesar(text, int(s)));

Chk this once and let me know

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote