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
Masteriza [31]
3 years ago
7

Write a function called st_dev. St_dev should have one #parameter, a filename. The file will contain one integer on #each line.

The function should return the population standard #deviation of those numbers.
Computers and Technology
1 answer:
kodGreya [7K]3 years ago
6 0

Answer:

  1. import statistics
  2. def st_dev(file_name):
  3.    with open(file_name) as file:
  4.        data = file.readlines()
  5.        numList = []
  6.        for x in data:
  7.            numList.append(int(x))
  8.        
  9.        return statistics.pstdev(numList)
  10. print(st_dev("text1.txt"))

Explanation:

The solution code is written using Python.

To ease the calculation task, we can import Python statistics module to use the pstdev method to calculate the population standard deviation of a list of numbers (Line 1).

Next, create a st_dev function that take single argument file_name (Line 3). In the function, it will open the input file and read the data line by line (Line 4-5). Create a for loop to traverse through each line of the data which is an integer and append it to numList (Line 7-8). We can pass the numList to pstdev method (Line 10) and return the resulting standard deviation value as output.

We test the function by passing a file which hold a list of integer values in each line (Line 12).

8

9

12

11

21

15

16

10

7

13

And the output we shall get is 4.019950248448356

You might be interested in
A vertical set of data in a spreadsheet is called a _____. row column cell table
maw [93]
A vertical set of data in a spreadsheet is called a column. This is as a horizontal set of data would be called a row.
A bit like how a brick column stands up right, and is made of rows of brights.
7 0
3 years ago
What is stored by a reference variable?What would be the results after the following code was executed? int[] array1 = {10, 20,
Romashka [77]

Answer:

Both array1 and array2 would be pointing to the array with {20,30,50,60}.

Explanation:

array1 and array2 are references (pointers) to the array.

array1 = array2; only makes the array1 variable point to the same destination as the array2 variable.

The next assignment array2 = array1; therefore doesn't change anything. array2 was already pointing to this location.

8 0
3 years ago
What instruments are used the measure voltage, current, and resistance
Salsk061 [2.6K]
To measure voltage, current, and resistance you would use a multimeter
4 0
3 years ago
what is the definition of web search(ing)? when I look it up it keeps trying to give me definitions for search engines but that'
AysviL [449]

Answer:

Web searching is when one types keywords into a search engine to retrieve data.

You're welcome.

6 0
3 years ago
Read 2 more answers
6. The
nordsb [41]

In spermatocytogenesis, a diploid spermatogonium, which resides in the basal compartment of the seminiferous tubules, divides mitotically, producing two diploid intermediate cells called primary spermatocytes.

Fertilization takes place in the fallopian tubes, which connect the ovaries to the uterus. Fertilization happens when a sperm cell successfully meets an egg cell in the fallopian tube.

7 0
3 years ago
Other questions:
  • Which button is used to open the Start menu in Windows Vista?
    14·1 answer
  • Are there protections for people in terms of what data can be collected by different sites?
    10·1 answer
  • Yo who do u add a pic on here
    13·1 answer
  • When writing code, how can printing be useful?
    15·1 answer
  • I have a Dell laptop and last night it said that it needed to repair it self and asked me to restart it. So I did but every time
    11·1 answer
  • Universal Containers is designing a new community using the Customer Community license type. They would like to have the users c
    6·1 answer
  • Plsss 30 points!!!!
    6·1 answer
  • Where would you go to access frequently used icons?
    12·2 answers
  • Under what scenarios can we clear the NVRAM by moving the PSWD jumper to the RTCRST<br> pins?
    8·1 answer
  • _is the joining of two or more electrical conductors by mechanically twisting the conductors together or by using a special spli
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!