Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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