subject

Intro to python

Chapter 6 Solution

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:
A. 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.
B. 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: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:40
Write an assembly program with the following specifications.a). in the main block, you should have two registers r4 and r5. they should be checked in an infinite loop. if r4 is greater than r5, then the greater subroutine will be called. if r4 is less than r5, then the less subroutine will be called. if r4 equals r5, then no operations will be done
Answers: 1
question
Computers and Technology, 22.06.2019 11:10
The total cost of textbooks for the term was collected from 36 students. create a histogram for this data. $140 $160 $160 $165 $180 $220 $235 $240 $250 $260 $280 $285 $285 $285 $290 $300 $300 $305 $310 $310 $315 $315 $320 $320 $330 $340 $345 $350 $355 $360 $360 $380 $395 $420 $460 $460
Answers: 2
question
Computers and Technology, 23.06.2019 06:00
How can a user delete a drawing object
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1
You know the right answer?
Intro to python

Chapter 6 Solution

read_file = open('numbers. txt', 'r')
Questions
question
Mathematics, 04.07.2020 23:01
question
Mathematics, 04.07.2020 23:01
question
Mathematics, 04.07.2020 23:01
question
Mathematics, 04.07.2020 23:01
question
Mathematics, 05.07.2020 01:01
Questions on the website: 13722363