Focus on Basic file operations, exception handling Save a copy of the file module6data.txt (attached to the assignment) 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
Save a copy of the file module6data.txt (attached to the assignment)
Write a
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 3 images