Question: Q 1 . / 5 8 a . Write a function encrypt ( ) that takes a str s 1 as input and creates a

Q1./58
a. Write a function encrypt() that takes a str s1 as input and creates a new str s2 by subtracting 9 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 s2 by adding 9 to the ascii code for each character in the string sI.
c. Read each line of a file infileA2Q1.txt 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 (non-empty) 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.
Q 1 . / 5 8 a . Write a function encrypt ( ) that

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 Programming Questions!