Complete the code to calculate the mean of the data array using NumPy.
import numpy as np data = np.array([10, 20, 30, 40, 50]) mean_value = np.[1](data) print(mean_value)
sum instead of mean will give the total, not the average.median calculates the middle value, not the average.The mean function calculates the average value of the array elements.
Complete the code to calculate the standard deviation of the data array using NumPy.
import numpy as np data = np.array([5, 10, 15, 20, 25]) std_dev = np.[1](data) print(std_dev)
var calculates variance, not standard deviation.mean calculates average, not spread.The std function calculates the standard deviation, which shows how spread out the numbers are.
Fix the error in the code to calculate the median of the data array using NumPy.
import numpy as np data = np.array([3, 1, 4, 1, 5]) median_value = np.[1](data) print(median_value)
mode is not available in NumPy and causes an error.mean calculates average, not the middle value.The median function finds the middle value when the data is sorted.
Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.
words = ['apple', 'bat', 'carrot', 'dog', 'elephant'] lengths = {word: [1] for word in words if len(word) [2] 3} print(lengths)
== filters only words with length exactly 3.<= includes words with length 3 or less.The dictionary comprehension uses len(word) to get the length and filters words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase keys and values greater than 10.
data = {'a': 5, 'b': 15, 'c': 25}
result = { [1]: [2] for k, v in data.items() if v [3] 10 }
print(result)k.lower() does not change keys to uppercase.< or == filters wrong values.The dictionary comprehension creates keys as uppercase letters using k.upper(), keeps values as v, and filters values greater than 10 using >.