Ask Question
13 September, 15:32

I need the answer for Edhesive Question 9.7 Question 4

+4
Answers (1)
  1. 13 September, 17:42
    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?
Get an answer to your question ✅ “I need the answer for Edhesive Question 9.7 Question 4 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers