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
In Microsoft Windows, which of the following typically happens by default when a file is "double-clicked"
Elenna [48]
Depending on the type of file, it normally runs or opens.
4 0
3 years ago
Read 2 more answers
Explain<br> the three types of periodic<br>maintanance. .​
LenaWriter [7]

Answer:

poop i think

Explanation:

6 0
3 years ago
When you use the Filter feature, what appears in each column label
Scrat [10]
<span>an arrow  ..............................</span>
5 0
3 years ago
(BRAINLIEST FOR FIRST CORRECT ANSWER) Mark (all) the statements that best describe the use of spreadsheets and tables in present
mel-nik [20]

the answer is Headers should be descriptive of the cell content, The font size should be at least 18-point. hope this helps!!!

5 0
3 years ago
Flexplace and telecommuting are similar in that both allow you to _____. work in a location away from the office work different
viva [34]
Flexplace and telecommuting are similar in that both allow you to work in a different location four days a week. 
3 0
3 years ago
Other questions:
  • True or False: clicking ads and pop-ups like the one below could expose your computer to malware.
    11·2 answers
  • Test Average and Grade
    12·1 answer
  • Which note-taking method quickly captures and organizes information?
    9·2 answers
  • List and describe the tools for all the main stages of app/application development.
    11·1 answer
  • Write the definition of a class clock. the class has no constructors and three instance variables. one is of type int called hou
    12·1 answer
  • Which of the following does every font that you choose communicate, either on a conscious or subconscious level?
    10·2 answers
  • Your mom wants to purchase a computer. She has heard about how the Windows 8 operating system is best-geared for a touch-enabled
    10·2 answers
  • Function of dobji dzong​
    14·1 answer
  • Write a flowchart and C code for a program that does the following: Uses a do...while loop. Prints the numbers from 1 to 10 with
    13·1 answer
  • In the year, , the American Department of Defense put a military research network, called ARPANET online.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!