Complete the code to calculate the mean of the list 'data'.
mean_value = sum(data) / [1]
The mean is the sum of all values divided by the number of values, which is given by len(data).
Complete the code to calculate the median of the sorted list 'data_sorted'.
n = len(data_sorted) median = (data_sorted[n // 2] if n % 2 != 0 else (data_sorted[n // 2 - 1] + data_sorted[[1]]) / 2)
For even number of elements, the median is the average of the two middle values at positions n//2 - 1 and n//2.
Fix the error in the code to calculate the variance of the list 'data'.
mean = sum(data) / len(data) variance = sum((x - mean)[1] for x in data) / len(data)
To calculate variance, subtract the mean from each value, square the result using ** 2, then average.
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3}The dictionary comprehension maps each word to its length using len(word). The condition filters words longer than 3 using >.
Fill all three blanks to create a dictionary of uppercase words and their lengths for words longer than 4 characters.
result = [1]: [2] for w in words if len(w) [3] 4
The dictionary comprehension uses the uppercase word as the key with w.upper(), the length as the value with len(w), and filters words longer than 4 with >.