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
What is the interface in Java programming Language? Why do we need to use it?
Alenkasestr [34]

To accustom to several different language-speaking countries. One program is often used internationally so having a language setup is very important.

6 0
3 years ago
1. Which of the following is NOT an example of systems software? (Points : 1)
vladimir2022 [97]
The answer is "operating systems" brcause you need that that to use the rest
' 
4 0
2 years ago
Read 2 more answers
Fifty-three percent of U.S households have a personal computer. In a random sample of 250 households, what is the probability th
aleksley [76]

Answer:

The correct Answer is 0.0571

Explanation:

53% of U.S. households have a PCs.

So, P(Having personal computer) = p = 0.53

Sample size(n) = 250

np(1-p) = 250 * 0.53 * (1 - 0.53) = 62.275 > 10

So, we can just estimate binomial distribution to normal distribution

Mean of proportion(p) = 0.53

Standard error of proportion(SE) =  \sqrt{\frac{p(1-p)}{n} } = \sqrt{\frac{0.53(1-0.53)}{250} } = 0.0316

For x = 120, sample proportion(p) = \frac{x}{n} = \frac{120}{250} = 0.48

So, likelihood that fewer than 120 have a PC

= P(x < 120)

= P(  p^​  < 0.48 )

= P(z < \frac{0.48-0.53}{0.0316}​)      (z=\frac{p^-p}{SE}​)  

= P(z < -1.58)

= 0.0571      ( From normal table )

6 0
3 years ago
What dose a bios system do?
ANTONII [103]
BIOS instructs the computer on how to preform basic functions such as booting and keyboard control. It is also used to identify and configure the hardware in a computer
4 0
2 years ago
Read 2 more answers
Which of the following is typically used in a flowchart to indicate a decision?
Vilka [71]
Diamond is typically used in a flowchart or indicate a decision.
6 0
3 years ago
Other questions:
  • If the pc­doctor software is installed on a computer's hard drive, what two different ways can the program be started?
    7·1 answer
  • There are 22 gloves in a drawer: 5 pairs of red gloves, 4 pairs of yellow, and 2 pairs of green. You select the gloves in the da
    12·1 answer
  • Why is it a good idea to leave an interview being courteous and polite?
    10·1 answer
  • Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative intege
    10·1 answer
  • BRAINLIEST !!A game design document is like a diary for game developers.
    11·1 answer
  • How many bits can a memory chip with the below configuration support? For full credit, show how you got the answer.
    15·1 answer
  • What can you do to help create a safe online environment?
    8·2 answers
  • Imma say something random...
    13·2 answers
  • What keyword is used in Java to create a parent/child relationship between two classes?
    14·1 answer
  • Anyone knows the answer for 6.1.4 Happy Birthday! codehs
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!