Create and save a file of the number below as module6data.txt: 26 O 76 -91 85 -44 85 -95 -34 83 -64 -76 -41 89 0 83 -99 -69 8 -79 0 -32 -49 -89 85 79 -28 56 19 -93 -21 -23 82 51 -80 l 62 -78 -8 71 28 -73 0 -45 -73 28 -5 O -70 63 -36 -72 0 -76 -24 -59 0 -54 83 35 -3 88 -14 29 -35 17 27 -61 -42 49 83 38 79 -80 33 8 41 96 -94 46 71 8 76 -63 -36 93 -82 -68 -20 69 -57 -84 -29 -17 77 36 -89 -94 62 10 -69 -43 Write a program in python that will a. Open the file module6data.txt b. Create a second file named processed.txt c. Read the numbers from the first file one at a time. For each number write into the second file, if possible, its i. square ii. square root. iii. reciprocal (1/number) each on a separate line. • Use a math module function for the square root. • Use exception handling to trap possible errors. Error messages should be reported to the screen. d. Report the number of items in the original file and the number that were successfully stored in the second file. e. Report the number (count) of each type of error: ValueError, ZeroDivisionError, TypeError
Focus on Basic file operations, exception handling
Create and save a file of the number below as module6data.txt:
26
O
76
-91
85
-44
85
-95
-34
83
-64
-76
-41
89
0
83
-99
-69
8
-79
0
-32
-49
-89
85
79
-28
56
19
-93
-21
-23
82
51
-80
l
62
-78
-8
71
28
-73
0
-45
-73
28
-5
O
-70
63
-36
-72
0
-76
-24
-59
0
-54
83
35
-3
88
-14
29
-35
17
27
-61
-42
49
83
38
79
-80
33
8
41
96
-94
46
71
8
76
-63
-36
93
-82
-68
-20
69
-57
-84
-29
-17
77
36
-89
-94
62
10
-69
-43
Write a program in python that will
a. Open the file module6data.txt
b. Create a second file named processed.txt
c. Read the numbers from the first file one at a time. For each number write into the
second file, if possible, its
i. square
ii. square root.
iii. reciprocal (1/number)
each on a separate line.
• Use a math module function for the square root.
• Use exception handling to trap possible errors. Error messages should be reported to the
screen.
d. Report the number of items in the original file and the number that were successfully
stored in the second file.
e. Report the number (count) of each type of error: ValueError, ZeroDivisionError,
TypeError
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images