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
A good algorithm should have which three components?
DiKsa [7]

A good algorithm should have these three components: C. steps, order, and outcomes.

<h3>What is an algorithm?</h3>

An algorithm simply refers to a standard formula which is made up of a set of finite steps and instructions that are executed on a computer system, in order to enable a software solve a particular problem under appropriate conditions.

In Computer technology, there are three (3) components that a good algorithm should have these include the following:

  • Steps
  • Order
  • Outcomes

Read more on algorithm here: brainly.com/question/24793921

#SPJ1

5 0
1 year ago
POINT AND BRAINLIEIST GIVE AWAY!!!
Sonbull [250]

Answer:

Hey whats up

Explanation:

Count me in chief! I love when fellow user give out mighty points

7 0
3 years ago
Read 2 more answers
A _____ software system determines the steps needed to produce components and instructs the machines that do the work.
konstantin123 [22]

Answer:

A computer-aided manufacturing or (cam) software system

Explanation:

Hope I could help :)

8 0
2 years ago
Which of the following is not an operating system
mrs_skeptik [129]

Answer:

C

Explanation:

I hope this helped.

3 0
3 years ago
Read 2 more answers
Write the definition of a method dashedLine, with one parameter, an int. If the parameter is negative or zero, the method does n
ZanzabumX [31]

Answer:

import java.util.Scanner;

public class DashLine {

public static void main(String[] args) {

// Declaring variables

int n;

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

// Getting the input entered by the user

System.out.print("Enter a number :");

n = sc.nextInt();

// calling the method by passing the user entered input as argument

dashedLine(n);

}

//This method will print the dashed line for number greater than zer

private static void dashedLine(int n) {

if (n > 0) {

for (int i = 1; i <= n; i++) {

System.out.print("-");

}

System.out.println();

}

}

}

Explanation:

5 0
3 years ago
Other questions:
  • We will pass you 2 inputsan list of numbersa number, N, to look forYour job is to loop through the list and find the number spec
    12·1 answer
  • How does microchip work
    12·1 answer
  • Create an instance of your queue that accepts java.lang.String Objects. Starting with an empty queue, use the enqueue(E e) metho
    15·1 answer
  • Assume that input file references a Scanner object that was used to open a file. Which of the following while loops shows the co
    6·1 answer
  • If a user inserts a piece of clip art over some text but does not want the art to block the text, the user should select
    14·2 answers
  • A production house needs an operating system that captures saves and generates information within a specific time. Which type of
    11·1 answer
  • Hey im b---o---r---e---d dont report cuz if u do ur l a m e :)
    14·1 answer
  • if you were determining what was expected of you simply by looking at media, what messages would you take away?
    8·2 answers
  • Does nature behave the exact same way as fractals?
    15·1 answer
  • What are some of the most common obstacles in video games?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!