subject

Read_file = open('numbers. txt', 'r')
file_numbers = read_file. read()
read_file. close()
list_values = file_numbers. split()
list_length = len(list_values)

for i in range(list_length):
list_values[i] = float(list_values[i])

List_sum = sum(list_values)

Average_value = (List_sum)/list_length

print(Average_value)

Problem:

Modify the program you wrote for Chapter 6 Exercise 6 so it handles the following
exceptions:
• It should handle IOError exceptions that are raised when the file is opened
and data is read from it by printing "Trouble opening file. Try again." and
not executing any more of the code.
• It should handle any ValueError exceptions that are raised when the items
that are read from the file are converted to a number by printing "File must have
only numbers. Try again." and not executing any more of the code.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 00:30
Match the sentence fragment in the first column with the appropriate ending in the second column. a little per favore?
Answers: 1
question
Computers and Technology, 25.06.2019 06:00
Sam needs to create a spreadsheet for his coworkers. they will need to follow a crossed a long road of data. sam would like to make his spreadsheet easy to read. sam should
Answers: 1
question
Computers and Technology, 25.06.2019 17:40
4) wilkes continues to discuss the concept of time and how it relates to the type of photography he does. why do you feel that the concept of time is of suck importance to him as a photographer? 5) unit 10 explores photographs with movement in them such as wildlife and documentary photography. wilkes takes the idea of movement in photography to a different level. do you feel the tips and information that you have learned in unit 10 is applicable to the type of photography that wilkes does? answer as soon as possible im so confused
Answers: 1
question
Computers and Technology, 25.06.2019 23:30
If i write one question multiple times.so will it be permanently fitted in my brain
Answers: 1
You know the right answer?
Read_file = open('numbers. txt', 'r')
file_numbers = read_file. read()
read_file. clos...
Questions
question
Mathematics, 11.06.2021 07:30
question
Mathematics, 11.06.2021 07:30
question
Mathematics, 11.06.2021 07:30
question
Mathematics, 11.06.2021 07:40
question
English, 11.06.2021 07:40