Assume that a file containing a series of integers is named numbers.txt. Write a program that calculates average of all thernumbers stored in the file and prints the average on the screen. The code...


Assume that a file containing a series of integers is named numbers.txt. Write a program that calculates average of all thernumbers stored in the file and prints the average on the screen.


The code that does not work. How can I add try except ZeroDivision Error into the code?


file=open("numbers.txt", "r");
count=0
sum=0
content=file.readlines()
for nums in content:
    num=nums.split("")
    for i in num:
        sum=sum+int(i)
        count=count+1
print("Average:"+str(sum/count))



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here