Question: 3 . Define a list list 1 = [ 1 2 , 3 5 . 8 , - 9 , 2 3 , - 1

3. Define a list list1=[12,35.8,-9,23,-18.0,54]. Next, for each line of the file infileA2Q3.txt do the following:
a. Remove any whitespace characters at the end of the line and convert to an integer
n and print the value of n
b. If n >10 set i =0.25*n; otherwise set i = n
c. Print list1[i] with a suitable message.
d. Print list1[0]//i with a suitable message.
If any exceptions occur, print the default error message for the exception. For ValueError also print a custom message in addition to the default error message, then continue with the next item in the file
infileA2Q3.txt contains following text:
2
-1
7.5
1
16
0
9
2
3 . Define a list list 1 = [ 1 2 , 3 5 . 8 , - 9

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