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
netineya [11]
3 years ago
15

Write a function named average_value_in_file that accepts a file name as a parameter and reads that file, assumed to be full of

numbers, and returns the average (mean) of the numbers in that file. The parameter, filename, gives the name of a file that contains a list of numbers, one per line. You may assume that the file exists and follows the proper format. For example, if a file named input.txt contains the following numbers
Computers and Technology
1 answer:
noname [10]3 years ago
6 0

def average_value_in_file(filename):

   f = open(filename)

   total = 0

   count = 0

   for x in f.read().splitlines():

       total += int(x)

       count += 1

   return total/count

print(average_value_in_file("input.txt"))

I used an input file that looks like this:

1

1

1

1

You might be interested in
What is the term for the process of swapping items between memory and storage?
Naddik [55]
Swapping pages of memory from core memory and disk is called swapping in Unix, and paging in Microsoft.
3 0
3 years ago
Read 2 more answers
When defining an array of class objects, how do you pass arguments to the constructor for each object in the array?
Nuetrik [128]
Basically, the array[ index ] is the name of the object so when you  populate the array you'd have statement[s] like:

array[ index ] = new ClassName( arg0, arg1, arg2 );
8 0
3 years ago
A portable electronic device that can be used in an emergency to stop someone’s heart from going out of rhythm is called a/an
JulsSmile [24]
It is called a Heart pace maker
7 0
3 years ago
Read 2 more answers
With a _____ network connection, the computers and other devices on the network are physically connected via cabling to the netw
Lostsunrise [7]
Wired
........................
6 0
3 years ago
How to share excel file for multiple users office 365?.
Sholpan [36]

Answer:

You would need that person email to share it with them.

5 0
2 years ago
Read 2 more answers
Other questions:
  • You respond to an "unknown medical problem" in an area commonly populated by Hispanic Americans. You arrive to find several indi
    13·1 answer
  • A Color class has a constructor that accepts three integer parameters: red, green and blue components in the range of 0 ... 255
    6·1 answer
  • What service in Windows Server 2016 authenticates remote users and computers to the Windows domain and its corporate network res
    9·1 answer
  • What scientific principle would a plumber need to know when designing and installing plumbing a new construction
    13·1 answer
  • .Prove that f(n) = 3logn + loglogn is capital omega (logn) , what is O(n)?
    8·1 answer
  • The mechanism that establishes the medullary osmotic gradient depends most on the permeability properties of the ________. A. co
    5·1 answer
  • Differentiate agricultural waste from hazardous waste.​
    9·1 answer
  • How to prepare and draw a corresponding flowchart to compute the sum and product of all prime numbers between 1 and 50
    7·1 answer
  • A proposal is also known as a
    14·2 answers
  • Kevin, a manager at FitPlus fitness club, owns a website that updates information regarding his fitness club. He created backgro
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!