Complete the code to import the library that helps speed up Python loops.
import [1]
The numba library can speed up Python loops by compiling them to fast machine code.
Complete the code to create a fast function using numba's decorator.
@[1] def fast_sum(arr): total = 0 for x in arr: total += x return total
The @njit decorator from numba compiles the function without Python overhead, making it very fast.
Fix the error in the code by completing the blank to convert a list to a NumPy array.
import numpy as np my_list = [1, 2, 3, 4] my_array = np.[1](my_list) print(my_array)
The np.array() function converts a list into a NumPy array.
Fill both blanks to create a dictionary comprehension that stores squares of numbers greater than 3.
squares = {x: x[1]2 for x in range(1, 6) if x [2] 3}The ** operator is used for exponentiation (power), and > checks if x is greater than 3.
Fill all three blanks to create a dictionary comprehension that stores uppercase keys and values greater than 0.
result = { [1]: [2] for k, v in data.items() if v [3] 0}The keys are converted to uppercase with k.upper(), values are v, and the condition checks if v > 0.