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
True or false? A medical assistant can check for available exam rooms and providers using an electronic scheduling system.
lutik1710 [3]
This is true m8 hope this helps
4 0
3 years ago
8.Arun wrote a program to divide two numbers by accepting from user. But he was not getting the intended result when the divisor
Kryger [21]
Kakapo our new generation is a lot more work
4 0
4 years ago
Which of the following is used by credit card companies to determine APR?
kodGreya [7K]
Prime rate + credit history (APEX)
4 0
3 years ago
Read 2 more answers
PLEASE ANSWER DUE TODAY
never [62]

Answer:

I am not sure on exactly how they want this but this is how I'd fill it out:

Also I can't see the whole question so I'll fill it out as best as I can.

Explanation:

Employee 1 - 78 hours - $2 an hour - $2,184 -

Employee 2 - Numbers of hours worked - their hourly pay - hours x hourly pay x days worked (if they work everyday for 2 weeks you'd x's it by 14.)

All I see is employee 1 and 78 hours so I tried my best!

Please mark brainliest and 5 stars, thanks!

4 0
3 years ago
What are the home row keys?
kramer
ASDF JKL; are the home row keys.
7 0
3 years ago
Other questions:
  • ____ takes the idea of breaking down a program into separate and reusable functions to the next level by focusing on the encapsu
    10·1 answer
  • Each object that is created from a class is called a(n) ____________ of the class.
    5·2 answers
  • WILL GIVE 100 POINTS AND GIVE BRAINIEST TO THE FIRST PEOPLE THAT ANSWER CORRECTLY!!!!!! Marcus wants to create a spreadsheet wit
    13·2 answers
  • When discussing the data-modeling building blocks, anything (a person, a place, a thing, or an event) about which data are to be
    15·1 answer
  • Why is sequencing important?
    11·2 answers
  • Discuss what technologies you might see in use at an enterprise. For example, where would you most likely see fiber-optic Ethern
    9·1 answer
  • Does anyone know how to fix this? Everytime i make a new page it only types in the middle of the page. I want to type at the top
    11·1 answer
  • Consider the following method.
    14·1 answer
  • "what is the common information listed under the ip section of pdu details as compared to the information listed under the osi m
    7·1 answer
  • In a(n) ____________________ device, the movement of electrons performs essentially the same functions as gears and wheels in me
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!