0
0
Data Analysis Pythondata~10 mins

Why statistics validates hypotheses in Data Analysis Python - 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 sample data.

Data Analysis Python
import numpy as np
sample = [5, 7, 8, 6, 9]
mean_value = np.[1](sample)
print(mean_value)
Drag options to blanks, or click blank then click option'
Amean
Bmedian
Cmode
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using median instead of mean
Using sum without dividing by count
2fill in blank
medium

Complete the code to calculate the standard deviation of the sample.

Data Analysis Python
import numpy as np
sample = [5, 7, 8, 6, 9]
std_dev = np.[1](sample, ddof=1)
print(std_dev)
Drag options to blanks, or click blank then click option'
Avar
Bstd
Cmean
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using variance instead of standard deviation
Forgetting to set ddof=1 for sample std deviation
3fill in blank
hard

Fix the error in the code to calculate the t-statistic for hypothesis testing.

Data Analysis Python
import numpy as np
sample = [5, 7, 8, 6, 9]
mean_sample = np.mean(sample)
std_sample = np.std(sample, ddof=1)
n = len(sample)
t_stat = (mean_sample - 6) / (std_sample / [1])
print(t_stat)
Drag options to blanks, or click blank then click option'
Anp.sqrt(n)
Bn
Cnp.square(n)
D1/n
Attempts:
3 left
💡 Hint
Common Mistakes
Using n instead of sqrt(n)
Using 1/n which is incorrect for standard error
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Data Analysis Python
words = ['data', 'is', 'fun', 'and', 'useful']
lengths = {word: [1] for word in words if [2] > 3}
print(lengths)
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for length
Checking word > 3 instead of length
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of uppercase keys and values greater than 0.

Data Analysis Python
data = {'a': 1, 'b': -2, 'c': 3}
result = { [1]: [2] for k, v in data.items() if v [3] 0 }
print(result)
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper()
Using < instead of > in condition