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, 21.06.2019 21:00
If you have a lien on your vehicle, you cannot apply for a duplicate copy of your vehicle’s certificate of title. true or false
Answers: 1
question
Computers and Technology, 22.06.2019 12:00
Which of the following “invisible” marks represents an inserted tab?
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. which step can possibly increase the severity of an incident? a. separating sensitive data from non-sensitive data b. immediately spreading the news about the incident response plan c. installing new hard disks d. increasing access controls
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Choose the correct citation for the case which established the "minimum contacts" test for a court's jurisdiction in a case. select one: a. brown v. board of education of topeka, 347 u.s. 483 (1954). b. international shoe co. v. washington, 326 u.s. 310 (1945) c. haynes v. gore, 531 u.s. 98 (2000). d. international shoe co. v. washington, 14 u.s. code 336.
Answers: 1
You know the right answer?
Read_file = open('numbers. txt', 'r')
file_numbers = read_file. read()
read_file. clos...
Questions
question
Mathematics, 04.12.2020 20:00
question
Mathematics, 04.12.2020 20:00
question
World Languages, 04.12.2020 20:00
question
Chemistry, 04.12.2020 20:00
question
Arts, 04.12.2020 20:00
question
Mathematics, 04.12.2020 20:00
question
Mathematics, 04.12.2020 20:00
Questions on the website: 13722360