0
0
SciPydata~10 mins

First SciPy computation - 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 SciPy library.

SciPy
import [1]
Drag options to blanks, or click blank then click option'
Ascipy
Bnumpy
Cpandas
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy instead of scipy
Forgetting to import the library
Using incorrect library names
2fill in blank
medium

Complete the code to calculate the mean of the array using SciPy.

SciPy
from scipy import stats

data = [1, 2, 3, 4, 5]
mean_value = stats.[1](data).mean
Drag options to blanks, or click blank then click option'
Amedian
Bdescribe
Cvariance
Dmode
Attempts:
3 left
💡 Hint
Common Mistakes
Using mode or median which do not return mean directly
Trying to call mean on a list
Using variance which returns variance, not mean
3fill in blank
hard

Fix the error in the code to compute the Euclidean distance between two points using SciPy.

SciPy
from scipy.spatial import distance

point1 = (1, 2)
point2 = (4, 6)
dist = distance.[1](point1, point2)
Drag options to blanks, or click blank then click option'
Ahamming
Bcosine
Cmanhattan
Deuclidean
Attempts:
3 left
💡 Hint
Common Mistakes
Using cosine which measures angle similarity
Using manhattan which sums absolute differences
Using hamming which counts differing bits
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

SciPy
words = ['apple', 'bat', 'carrot', 'dog']
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for value
Using less than instead of greater than in condition
Not filtering words by length
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase words and their lengths for words longer than 3 characters.

SciPy
words = ['apple', 'bat', 'carrot', 'dog']
result = { [1]: [2] for w in words if len(w) [3] 3}
Drag options to blanks, or click blank then click option'
Aw.upper()
Blen(w)
C>
Dw.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for keys
Not filtering words by length
Using word instead of length for values