Question: Write a function encrypt(msg) which takes an input variable msg and creates two files (msg1.txt and msg2.txt) where msg1.txt contains the odd characters of msg

Write a function encrypt(msg) which takes an input variable msg and creates two files (msg1.txt and msg2.txt) where msg1.txt contains the odd characters of msg in order and msg2.txt contains the even characters. You program should print Done! upon successful creation and writing of the message in the two text files.

The following shows the behavior of the function for some sample parameters.

>>> encrypt (hello world)

Done!

>>>

Q2. One pound is equal to 453 grams. Write a function lb2kg(weight) that converts and print the weight in pounds to kilograms. Note that 1000 grams = 1 kilogram. Your function should filter invalid inputs (E.g. values less than 0) and print Invalid input!.

The following shows the behavior of the function for some sample parameters.

>>> lb2kg (1) 0.453 kg

>>> lb2kg (-1)

Invalid input!

>>>

Q3. The file grades.txt given on D2L contains a list of grades.

Write a function grader(filename) that takes a file name as an input and then counts and prints the number of students in each letter grade group. Letter grades are assigned as follows: A>90, B>80, C>70, D>60, F<=60. Example behavior of the grader function. Note that the numbers in grades.txt will be different.

>>> grader (grades.txt)

A=4,B=6,C=11,D=7,F=3

*The grades.txt file contains the following*:

55 82 25 83 57 88 50 65 61 69 100 56 1 58 17 75 95 50 82 54 27 34 86 41 55 27 55 77 100 79 36 99 4 90 71 73 65 94 97 91 45 28 65 41 57 15 20 68 23 63 70 53 3 20 91 77 46 70 14 84 41 12 5 83 36 49 5 91 45 89 37 78 80 84 19 38 87 22 73 76 71 94 35 38 74 95 95 76 81 22 2 38 62 24 6 17 80 96 23 74

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