0
0
SciPydata~10 mins

Kolmogorov-Smirnov test in SciPy - Interactive Code Practice

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

Complete the code to import the Kolmogorov-Smirnov test function from scipy.stats.

SciPy
from scipy.stats import [1]

# Now you can use the function for the KS test
Drag options to blanks, or click blank then click option'
Aks_test
Bks_2samp
Ckolmogorov_smirnov
Dkstest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ks_2samp' which is for two-sample KS test, not one-sample.
Trying 'ks_test' which is not a valid function name.
Using 'kolmogorov_smirnov' which is not a function in scipy.stats.
2fill in blank
medium

Complete the code to perform a one-sample Kolmogorov-Smirnov test comparing data to a normal distribution.

SciPy
from scipy.stats import kstest, norm

result = kstest(data, [1])
print(result)
Drag options to blanks, or click blank then click option'
A'norm'
B'gaussian'
C'normal'
D'stdnorm'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'normal' which is not recognized by kstest.
Using 'gaussian' which is not a valid distribution name here.
Using 'stdnorm' which is not a valid string for this function.
3fill in blank
hard

Fix the error in the code to correctly perform a two-sample Kolmogorov-Smirnov test.

SciPy
from scipy.stats import [1]

result = ks_2samp(sample1, sample2)
print(result)
Drag options to blanks, or click blank then click option'
Aks_2samp
Bks_2sample
Cks2samp
Dkstest
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'kstest' which is for one-sample test.
Using 'ks2samp' without underscore which causes import error.
Using 'ks_2sample' which is not a valid function name.
4fill in blank
hard

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

SciPy
lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Checking if the word string is greater than 3, which is invalid.
Using the length without a comparison in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each uppercase word to its frequency only if frequency is greater than 1.

SciPy
freq_dict = [1]: [2] for [3] in word_counts if word_counts[[3]] > 1
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword_counts[word]
Cword
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as key without uppercasing.
Using the wrong variable name in the loop.
Using lowercase instead of uppercase for keys.