Complete the code to create a NumPy array from a Python list.
import numpy as np arr = np.[1]([1, 2, 3, 4, 5])
The np.array function converts a Python list into a NumPy array, which allows fast numerical operations.
Complete the code to calculate the mean of a NumPy array.
import numpy as np arr = np.array([10, 20, 30, 40, 50]) mean_value = arr.[1]()
The mean() method calculates the average value of the elements in the array.
Fix the error in the code to multiply two NumPy arrays element-wise.
import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) result = arr1 [1] arr2
The * operator performs element-wise multiplication between two NumPy arrays.
Fill both blanks to create a dictionary with words as keys and their lengths as values, but only for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3}
The dictionary comprehension uses len(word) to get the length and filters words with length greater than (>) 3.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] result = { [1]: [2] for word in words if len(word) [3] 3 }
The dictionary comprehension uses word.upper() as keys, len(word) as values, and filters words with length greater than (>) 3.