Question: Q 1 . / 5 8 a . Write a function encrypt ( ) that takes a str s 1 as input and creates a
Q
a Write a function encrypt that takes a str s as input and creates a new str s by subtracting from the ascii code for each character in the string sl
b Write a function decrypt that takes a str sl as input and creates a new str s by adding to the ascii code for each character in the string sI
c Read each line of a file infileAQtxt and pass the line after removing any whitespace characters at the end to the function encrypt The output of encrypt should be written on a new line in the output file encrypted.txt
d Read each line of a file encrypted.txt and pass the line after removing any whitespace characters at the end to the function decrypt The output of decrypt should be written on a new line in the output file decrypted.txt
e On the screen, print the total number of nonempty lines in encrypted.txt
infile contains this text :
I wandered lonely as a cloud
That floats on high o'er vales and hills,
When all at once I saw a crowd,
A host, of golden daffodils;
Beside the lake, beneath the trees,
Fluttering and dancing in the breeze.
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
