Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the mean of the data list.
ML Python
mean_value = sum(data) / [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to calculate the median of a sorted list named sorted_data.
ML Python
mid_index = len(sorted_data) // 2 median = sorted_data[[1]] if len(sorted_data) % 2 != 0 else (sorted_data[mid_index - 1] + sorted_data[mid_index]) / 2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to detect outliers using the interquartile range (IQR).
ML Python
iqr = q3 - q1 lower_bound = q1 - 1.5 * [1] upper_bound = q3 + 1.5 * iqr outliers = [x for x in data if x < lower_bound or x > upper_bound]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 3 characters.
ML Python
lengths = {word: [1] for word in words if len(word) [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a dictionary of uppercase words and their lengths for words longer than 4 characters.
ML Python
result = { [1]: [2] for w in words if len(w) [3] 4} Drag options to blanks, or click blank then click option'
Attempts:
3 left