0
0
SciPydata~10 mins

Why statistics quantifies uncertainty in SciPy - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the mean of the data using scipy.

SciPy
from scipy import stats

data = [2, 4, 6, 8, 10]
mean_value = stats.[1](data)
print(mean_value)
Drag options to blanks, or click blank then click option'
Atmean
Bmode
Cmedian
Dvariance
Attempts:
3 left
💡 Hint
Common Mistakes
Using mode or median instead of mean.
Trying to use variance which measures spread, not central value.
2fill in blank
medium

Complete the code to calculate the standard deviation of the data using scipy.

SciPy
from scipy import stats

data = [1, 3, 5, 7, 9]
std_dev = stats.[1](data)
print(std_dev)
Drag options to blanks, or click blank then click option'
Amode
Bsem
Cvariation
Dtstd
Attempts:
3 left
💡 Hint
Common Mistakes
Using sem which measures error, not spread.
Using mode which finds the most frequent value.
3fill in blank
hard

Fix the error in the code to calculate the 95% confidence interval for the mean.

SciPy
from scipy import stats
import numpy as np

data = [10, 12, 14, 16, 18]
mean = np.mean(data)
sem = stats.sem(data)
confidence = 0.95
h = sem * stats.[1].ppf((1 + confidence)/2, len(data)-1)
print(f"Confidence interval: ({mean - h}, {mean + h})")
Drag options to blanks, or click blank then click option'
Achi2
Bnorm
Ct
Df
Attempts:
3 left
💡 Hint
Common Mistakes
Using norm which is for large samples or known variance.
Using chi2 or f which are for variance tests.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.

SciPy
words = ['data', 'is', 'fun', 'and', 'useful']
lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword > 3
Dword == 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length.
Comparing the word string to a number.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths if length is greater than 2.

SciPy
words = ['hi', 'data', 'science', 'is', 'cool']
result = { [1]: [2] for word in words if [3] }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Clen(word) > 2
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for keys.
Not checking the length condition correctly.