1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MatroZZZ [7]
3 years ago
15

Modify the program you wrote for Chapter 6 Exercise 6 so it handles the following

Computers and Technology
1 answer:
Basile [38]3 years ago
6 0

Answer:

#try except

try:

   #opening the file

   read_file = open('numbers.txt', 'r')

   #Store the numbers in the variable file_numbers.

   file_numbers = read_file.read()

   #close the file

   read_file.close()

   #Split the number of files in list_values.

   list_values = file_numbers.split()

   #how many numbers are there

   list_length = len(list_values)

   try:

       #loop it up

       for i in range(list_length):

           list_values[i] = float(list_values[i])

       #Add up all the numbers, put into list_sum

       List_sum = sum(list_values)

       #heres how we average it

       Average_value = (List_sum)/list_length

       #print

       print(Average_value)

   except ValueError:

       print( "File must have only numbers. Try again." )

   #handles IOError exceptions

except IOError:

   #Display statement

   print("Trouble opening file. Try again.")

Explanation:

The python program uses the try-except exception handling method to catch errors in the code. The IOError is used for catching input and output errors in the program like file handling while the ValueError keyword in the except statement is used to catch data type errors from a return statement, calculation or user input.

You might be interested in
An office is facing a network issue. The technicians have determined that a virus affected the manager's computer. However, they
Margarita [4]

Answer:

The correct answer is: Bus Topology.

Explanation:

Bus Topology is a network setup where all the computers are connected to a single cable. Servers can connect easily to the network but it implies everyone connected has access to what everybody in the same network is doing. Security options are limited to no-existent under this topology.

In that case, if technicians cannot isolate a virus infection problem, it is the result of working with a bus topology where more than one computer is connected to the same network and every terminal has access to each terminal.

7 0
3 years ago
Which tool do you think would be the most useful if you were designing a logo for a business?
Maurinko [17]

Answer:

maybe a computer would be helpful

6 0
3 years ago
Read 2 more answers
25 POINTS!! NEED HELP ASAP!! Which of the following can be a problem for people with certain kinds of epilepsy?
olga_2 [115]
There is your answer:
Flashing images
5 0
2 years ago
Order the steps for accessing the junk email options in outlook 2016
Zinaida [17]

Answer:

What is the question here? lol

Explanation:

8 0
3 years ago
You can use the ____ method to search a string to determine whether it contains a specific sequence of characters.
kherson [118]

Answer:

in

Explanation:

Not an explanation, but here's an example:

if "mouth" in "mouthwatering":

   print("It is.")

else:

   pass

Another example:

if "water" in "mouthwatering":

   print("Yes.")

else:

   pass

6 0
2 years ago
Other questions:
  • Who is typically considered to be the father of computing
    6·1 answer
  • Which language is the most popular language for writing apple os x?
    9·1 answer
  • Colin Mackay Inc., a software company with its head office in Amsterdam, has employees across three continents. The company's pr
    10·1 answer
  • Choose a developing country and give 3 reasons why it is a developing country ​
    15·1 answer
  • Type the correct answer in the box.
    5·1 answer
  • When backing up a database, what is added to the file name?<br> On g metrix
    9·1 answer
  • Which feature is used to change how a presentation moves from slide to slide?
    14·1 answer
  • What is the correct order for writing the 3 dimensions for a 3D object? Here are the 3 dimensions:
    15·1 answer
  • Sharl downloads images from an online library and uses them in her work. The images are shared under the Creative Commons Attrib
    13·1 answer
  • What do people in the movie e.t think about the character E.T
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!