Question: Write a script in the file encrypt.py that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar
Write a script in the file encrypt.py 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.
def caesarciphertext shift:
encryptedtext
for char in text:
# Shift each character by 'shift' positions
shiftedchar chrordchar shift
encryptedtext shiftedchar
return encryptedtext
if namemain:
# Input from user
plaintext inputEnter the plaintext:
distance intinputEnter the distance value:
# Encrypting the plaintext
encryptedtext caesarcipherplaintext distance
printEncrypted text:", encryptedtext
Status: PASSED!
Check:
Test: Program outputs correct values when user inputs message and distance of
Reason: 'cdefgh' was found in the program's output.None
Timestamp: ::
Status: FAILED!
Check:
Test: Program outputs correct values when user inputs message and distance of
Reason: Unable to find abcde in the program's output.
Enter the plaintext: Enter the distance value: Encrypted text:
Error : AssertionError Unable to find abcde in the program's output.
Timestamp: ::
pls revise my python code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
