Ask Question

I need the answer for Edhesive Question 9.7 Question 4

+2
Answers (1)
  1. 15 May, 13:15
    0
    Question is incomplete here.

    Question 4 Using the prices. txt data file find the average of the values in the file

    I assume that you have a file prices. txt and it is having floating numbers separated by new line.

    for ex:

    $ cat prices. txt

    110.29

    239.10

    243.19

    435.22

    765.98

    987.76

    765

    876.09

    So we need to find the average and it should match when we caluculate through calculator or XL sheet average.

    Answer:

    Below Python code will accurately prints the average of above prices. txt file

    infile = open ('prices. txt', 'r')

    lines = infile. readlines ()

    infile. close ()

    mean = 0

    for line in lines:

    number = float (line)

    mean=mean+number

    mean=mean/len (lines)

    print (mean)

    Explanation:

    Result is : 552.82
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “I need the answer for Edhesive Question 9.7 Question 4 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers