Complete the code to create a NumPy array with 8-bit integers.
import numpy as np arr = np.array([1, 2, 3], dtype=[1]) print(arr.dtype)
The int8 type creates an array of 8-bit integers, which can store small integer values efficiently.
Complete the code to create a NumPy array with 16-bit integers.
import numpy as np arr = np.array([1000, 2000, 3000], dtype=[1]) print(arr.dtype)
int8 which is too small for these values.The int16 type stores 16-bit integers, which can hold larger integer values than int8.
Fix the error in the code to create a 32-bit integer array.
import numpy as np arr = np.array([100000, 200000, 300000], dtype=[1]) print(arr.dtype)
int8 or int16 which cause overflow.The values are too large for int8 or int16. Using int32 allows storing larger integers.
Fill both blanks to create a NumPy array with 64-bit integers and print its type.
import numpy as np arr = np.array([[1]], dtype=[2]) print(arr.dtype)
int8 which cannot hold large numbers.The number 10000000000 fits in 64-bit integers but not smaller types. The dtype int64 stores 64-bit integers.
Fill all four blanks to create a dictionary mapping integer types to their bit sizes.
int_sizes = { '[1]': [2], '[3]': [4] }The dictionary maps int8 to 8 bits and int16 to 16 bits.