Complete the code to calculate the sum of all elements in the array.
import numpy as np arr = np.array([1, 2, 3, 4, 5]) total = arr.[1]()
The sum() function adds all elements in the array to give the total.
Complete the code to find the average value of the array elements.
import numpy as np arr = np.array([10, 20, 30, 40, 50]) avg = arr.[1]()
The mean() function calculates the average of all elements.
Fix the error in the code to find the maximum value in the array.
import numpy as np arr = np.array([3, 7, 2, 9, 5]) max_value = arr.[1]()
The max() function returns the largest value in the array.
Fill both blanks to create a dictionary of word lengths for words longer than 3 letters.
words = ['data', 'is', 'fun', 'science', 'ai'] lengths = {word: [1] for word in words if len(word) [2] 3}
We use len(word) to get the length, and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase keys and values greater than 0.
data = {'a': 1, 'b': -2, 'c': 3}
result = { [1]: [2] for k, v in data.items() if v [3] 0 }Keys are converted to uppercase with k.upper(), values are v, and we filter values greater than 0 using >.