0% found this document useful (0 votes)
24 views

Assignment Python Standard Deviation Variance Quartiles

Uploaded by

Madam Azimah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Assignment Python Standard Deviation Variance Quartiles

Uploaded by

Madam Azimah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Subtopic : Standard Deviation and Variance

1. Find the mean value for sepal_length column by using the function in Numpy. Display
the mean value as follows: “Mean value = __”

Write the code that you have type to complete the above task:

___________________________________________________________________________

___________________________________________________________________________

Answer scheme:
mean_numpy = np.mean(df.sepal_length)
print(“Mean value = ” str(mean_numpy))

2. Find the mean value for petal_length column by using the function in Statistics. Display
the mean value as follows: “Mean value for petal_length is ____”. The mean value
should be displayed in two decimal places.

Write the code that you have type to complete the above task:

___________________________________________________________________________

___________________________________________________________________________

Answer scheme:
mean_statistics = statistics.mean(df.petal_length)
print(“Mean value for petal_length is {:.2f} ”. format(mean_statistics))

3. Find the variance value for petal_width column by using the function in Statistics.

Write the code that you have typed to complete the above task:

___________________________________________________________________________

___________________________________________________________________________

Answer scheme:
statistics.variance(content. petal_width)

4. Find the standard deviation value for sepal_width column by using the function in
Statistics.

Write the code that you have typed to complete the above task:

___________________________________________________________________________

___________________________________________________________________________
Answer scheme:
statistics.stdev(content.sepal_width)

Subtopic : Quantile, Quartile and Interquartile

1. Find the first and third quartiles value for sepal_length column by using the function in
Numpy.

Answer scheme:
first_quartile = np.quantile(content.sepal_length, 0.25)
print(first_quartile)

third_quartile = np.quantile(content. sepal_length, 0.75)


print(third_quartile)

2. Find the second quartile (median) value for petal_length column by using the function in
Numpy.

Answer scheme:
second_quartile = np.quantile(content. petal_length, 0.50)
print(second_quartile)

3. Find the third quartile value for sepal_width column by using the function in Numpy.

Answer scheme:
third_quartile = np.quantile(content. sepal_width, 0.75)
print(third_quartile)

4. Find the max quartile value for petal_width column by using the function in Numpy.

Answer scheme:
max_quartile = np.quantile(content. petal_width, 1)
print(max_quartile)

5. Find all quartiles (0%, 25%, 50%, 75% and 100%) for petal_length column by using the function in
Numpy. Name the quartiles as min, first, second, third and max respectively.

Answer scheme:
min = np.quantile(content.petal_length, 0)
first = np.quantile(content.petal_length, 0.25)
second = np.quantile(content.petal_length, 0.50)
third = np.quantile(content.petal_length, 0.75)
max = np.quantile(content.petal_length, 1)

print("Min Quartile: ",min)


print("First Quartile: ",first)
print("Second Quartile: ",second)
print("Third Quartile: ",third)
print("Max Quartile: ",max)

6. Find the first, second, third quartile values for petal_width column by using the function
in Statistics. What are the values returned?

First Quartile = ____________


Second Quartile = ___________
Third Quartile = _____________

Answer scheme:

statistics.quantiles(df.petal_width, n=4, method='inclusive')

You might also like