Write a python program that will : a. Open the file data.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) Use a math module function for the square root. Use exception handling to trap possible errors. 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 of each type of error: ValueError, ZeroDivisionError, TypeError. these are the numbers in file data.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
Write a python program that will :
a. Open the file data.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)
Use a math module function for the square root.
Use exception handling to trap possible errors.
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 of each type of error: ValueError, ZeroDivisionError,
TypeError.
these are the numbers in file data.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
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images