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]
4 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]4 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
Carbon copy others who are..
My name is Ann [436]

Answer:

Is it Multiple Choice Question?

5 0
3 years ago
Read 2 more answers
PLS HURRY!!<br> Look at the image below!
Lady_Fox [76]

Answer:

Line 2: for numF in [3, 5]

Line 1: for numE in [2, 6]

Line 3: print(numE, numF)

Explanation:

From the outputs, the first number of the first output is 2. This means that <em>numE in [</em><em>2</em><em>, 6]</em> would be on the first line.

The second number of the first output is 3, concluding that <em>numF in [</em><em>3</em><em>, 5]</em> is within a nested loop, meaning it would be on the second line.

This leaves <em>print(numE, numF)</em> on line 3.

We can go through the lines step by step to check if we have placed them in the correct order:

Code

for numE in [2, 6]:

 for numF in [3, 5]:

   print(numE, numF)

During the first iteration, numE = 2 and numF = 3.

Output: 2, 3

Since [3, 5] is in a nested loop, we need to finish iterating all of its numbers before numE moves to the next number, so:

numF moves to 5, numE stays at 2.

Output: 2, 5

Since we have finished iterating through [3, 5], numE moves to 6 and numF starts back at 3:

Output: 6, 3

numE still stays at 6 and numF iterates to 5 since [3, 5] is in a nested loop:

Output: 6, 5

The outputs match the outputs on the sheet, meaning we have correctly placed the code in order.

Hope this helps :)

5 0
3 years ago
Which of the following is the largest unit of information?
Mila [183]
What are the choices?

5 0
4 years ago
Read 2 more answers
A manufacturer wishes to design a hard disk with a capacity of 30 GB or more (using the standard definition of 1 GB = 2^30 bytes
never [62]

Answer:

4 Platters

Explanation:

The capacity of one platter

= 1024 x 2048 x 4096

<em>1 platter capacity= 8GB </em>

For a 30GB hard disk, we need

30/8  = 3.75  platters.

<em>we round off the answer  so 4 platters will be required.</em>

7 0
3 years ago
Suppose you will invest $100 per month at the beginning of the month for 40 years with interest rate
Alexeev081 [22]

Answer:

future value = 232369.1361

return % = 384.10 %

Explanation:

given data

principal = $100 per month

time = 40 year = 480 months

rate = 6.25 % yearly = 0.0625 yearly = 0.005208 monthly

to find out

total amount of capital at the end of your investment and percentage is  your total return

solution

so here future value formula is

future value = P \frac{(1+r)^{t-1}}{r} * (1+r)   ..........1

here r is rate and t is time and P is principal

so put all value

future value = 100 \frac{(1+0.005208)^{480-1}}{0.005208} * (1+0.005208)

future value = 232369.1361

so

Total capital at the end of investment-Total principle invested over the years

232369.1361 - 100 ( 12 × 40 )

184369.1361

so

Return % = \frac{184369.1361}{48000} × 100

return % = 384.10 %

5 0
3 years ago
Other questions:
  • Abigail is interested in connecting her tablet that usually connects to a wireless network, to her personal computer that usuall
    11·2 answers
  • How are devices connected to each other via Bluetooth? Choose two answers.
    11·1 answer
  • The critical path in a project network is:______ A. The Shortest path through the network. B. Longest path through the network.
    8·1 answer
  • When you create an internal hyperlink, you create the link that points to the bookmark using the anchor tag with which attribute
    15·1 answer
  • In programming, what is an integer number?
    14·2 answers
  • When installing EMT conduit that will be exposed to wet conditions, _______ fittings should be used.
    5·2 answers
  • Write a program that prompts the user to enter two positive integers less than 1,000,000,000 and the program outputs the sum of
    15·1 answer
  • What is the georgia connections academy administrative password? i want to install something.
    5·1 answer
  • Which Tab provides the command to add a hyperlink to a document?
    11·2 answers
  • Suppose we want an error correcting code that will allow all single-bit errors to be corrected for memory words of length 15. 1.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!