Loading...
Apply scalar operations to arrays using broadcasting.
Broadcasting allows NumPy to work with arrays of different shapes:
Write a function scalar_ops(arr, scalar) that performs operations.
Return a dictionary with:
arr = [1, 2, 3, 4], scalar = 2
{'add': [3, 4, 5, 6], 'multiply': [2, 4, 6, 8], 'power': [1, 4, 9, 16], 'divide': [0.5, 1.0, 1.5, 2.0]}Broadcasting applies scalar to each element