Question: A python program that does the following: 1. Reads a 'numbers.txt' file (2 lines at a time) that contains numbers (integers) ( copied down as
A python program that does the following:
1. Reads a 'numbers.txt' file (2 lines at a time) that contains numbers (integers) ( copied down as numbers.txt)
2. Reads a 'operators.txt' file (1 line at a time) that contains operators (copied down as operators.txt)
3. Applies the operator to the two numbers just read
4. Displays the result to a file 'output.txt'
Notes:
a. The program should handle exceptions gracefully
b. If an operator is illegal to perform on a set of numbers, the program should skip the
numbers and the operators and move to the following set of numbers and operator
c. You can resume execution of the code once an exception is raised: just use
the pass or continue keywords inside the except block.
Numbers.txt file
30
6
15
16
12
10
8
0
11
0
b
5
10
10
0
4
Operators.txt
/
+
*
-
/
+
*
-

Sample Interaction: File: numbers.txt File: operators.txt File: output.txt (read 2 lines at a (read 1 line at a (applies operator to two numbers read) time) time) 30 30 / 6 =5 6 + 15 + 16 = 31 15 12 * 10 = 1200 16 8 -0= 8 11 /0 - Division by zero not allowed (ZeroDivisionError) + b + 5 - Can not add characters (ValueError) # 10 * 10 = 100 0- 4=-4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
