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
How does a hard drive work?
BigorU [14]

a hard drive is a metal disk constantly spinning  while powered on.

The data is written with a  metal scratching the data onto the wheel.

8 0
3 years ago
What is malware? What are some signs that malware may be impacting the performance of your computer? How can you avoid malware?
Anni [7]

Answer:

Malware is a type of software that is specifically designed to disrupt, damage, or gain unauthorized access to a computer system. Malware can be spread through email attachments, online advertisements, websites, and other methods.

Some signs that malware may be impacting the performance of your computer include:

  • Your computer is running more slowly than usual
  • Your computer crashes frequently
  • Your computer has pop-up ads or other unwanted behavior
  • Your default homepage or search engine has changed without your permission
  • You see new icons or programs on your desktop that you didn't install

To avoid malware, you should be cautious when browsing the internet and avoid visiting suspicious websites. You should also avoid opening email attachments from unknown senders, and be wary of online advertisements. You can also protect your computer by using antivirus software and keeping it up to date.

3 0
1 year ago
Which type of operating system requires a keyboard in order to issue commands?
kicyunya [14]

Answer:

I said CLI.

Explanation:

''A command-line interface (CLI) processes commands to a computer program in the form of lines of text.''- Wikipedia

4 0
3 years ago
Match the job task to the occupation that would perform it. 1. Research the causes and treatments of diseases physical scientist
Trava [24]

Answer:

1.Physical scientist

2.Life scientist

3.Electrical engineer

4.aerospace engineer

Explanation:

5 0
3 years ago
Which page layout is most commonly used for a website with a large navigation menu?
mestny [16]

Explanation:

The Name is called, (navigation menu..)

to direct users 2 info., they look up...

7 0
2 years ago
Other questions:
  • Abigail is interested in connecting her tablet that usually connects to a wireless network, to her personal computer that usuall
    11·2 answers
  • While designing web pages for mobiles, the page content should be extensive such that the readers get the opportunity to explore
    5·2 answers
  • What do we call a subset of new media in which groups and their fans can interact directly?
    14·1 answer
  • Vitamins and minerals dissolve easily in water.True or false?
    5·1 answer
  • What is the difference between simple and complex waveforms?
    10·1 answer
  • Which of the following is not given to a client computer when it is first installed on a TCP/IP network so that it has the appro
    9·1 answer
  • 1. Which of the following statements are true about routers and routing on the Internet. Choose two answers. A. Protocols ensure
    9·2 answers
  • Design and implement an algorithm that gets a list of k integar values N1, N2,...Nk as well as a special value SUM. Your algorit
    10·1 answer
  • Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program be
    10·2 answers
  • The most important hardware device for connecting supercomputers over a wide area
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!