Complete the code to create a NumPy array from a Python list.
import numpy as np numbers = [1, 2, 3, 4, 5] arr = np.[1](numbers)
Use np.array() to convert a list into a NumPy array for vectorized operations.
Complete the code to add 5 to each element in the NumPy array using vectorized operation.
import numpy as np arr = np.array([1, 2, 3]) result = arr [1] 5
Adding 5 to each element uses the + operator in vectorized form.
Fix the error in the loop that adds 5 to each element in the list.
numbers = [1, 2, 3] for i in range(len(numbers)): numbers[i] = numbers[i] [1] 5
The loop should add 5 to each element using the '+' operator.
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 = { [1] : len([2]) for [1] in words if len([1]) > 3 }
Use the variable word as the key and to calculate length for each word in the list.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, but only for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = { [1] : [2] for [3] in words if len([3]) > 3 }
Use word.upper() as the key, len(word) as the value, and word as the loop variable.