Complete the code to calculate the average of the list using numpy.
import numpy as np numbers = [10, 20, 30, 40, 50] average = np.[1](numbers) print(average)
The np.mean() function calculates the average (mean) of the numbers in the list.
Complete the code to calculate the average of the numpy array.
import numpy as np arr = np.array([5, 15, 25, 35, 45]) avg = np.[1](arr) print(avg)
np.mean() calculates the average value of the elements in the numpy array.
Fix the error in the code to correctly calculate the average of the list.
import numpy as np values = [2, 4, 6, 8, 10] average = np.[1](values) print(average)
The correct numpy function to calculate average is np.mean(). Other options are not valid numpy functions.
Fill both blanks to create a dictionary with words as keys and their lengths as values, but only include words longer than 3 letters.
words = ['cat', 'house', 'dog', 'elephant'] lengths = {word: [1] for word in words if len(word) [2] 3} print(lengths)
The dictionary comprehension uses len(word) to get the length of each word and includes only words where length is greater than 3.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, including only words longer than 4 letters.
words = ['apple', 'bat', 'carrot', 'dog'] result = { [1]: [2] for w in words if len(w) [3] 4 } print(result)
The dictionary comprehension uses w.upper() as keys, len(w) as values, and filters words with length greater than 4.