0
0
SciPydata~10 mins

Pearson correlation 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 function for Pearson correlation from scipy.stats.

SciPy
from scipy.stats import [1]
Drag options to blanks, or click blank then click option'
Apearson
Bpearson_corr
Ccorrelation
Dpearsonr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pearson' instead of 'pearsonr'.
Trying to import 'correlation' which does not exist.
Using 'pearson_corr' which is not a valid function.
2fill in blank
medium

Complete the code to calculate the Pearson correlation coefficient between lists x and y.

SciPy
corr, p_value = pearsonr([1], y)
Drag options to blanks, or click blank then click option'
Adata_x
Blist_x
Cx
Dvalues_x
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable that does not exist like 'data_x'.
Passing the second list 'y' twice.
Using a wrong variable name.
3fill in blank
hard

Fix the error in the code to correctly calculate the Pearson correlation coefficient.

SciPy
corr, p_value = pearsonr(x, [1])
Drag options to blanks, or click blank then click option'
Ax
By
Cdata
Dz
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the same list twice.
Passing a variable that does not exist.
Swapping the order of arguments incorrectly.
4fill in blank
hard

Fill both blanks to create a dictionary with words as keys and their lengths as values, but only for words longer than 3 characters.

SciPy
{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.
Using the word variable in the condition instead of its length.
Using incorrect comparison operators.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words longer than 4 characters.

SciPy
{ [1]: [2] for word in words if [3] }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Clen(word) > 4
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for keys.
Using the word itself instead of its length for values.
Incorrect filter condition.