Arithmetic with NumPy Arrays:
Question: Create two numpy arrays of shape (2,2) with random integers between 1 and 10. Perform matrix multiplication between the two arrays and return the result.
Arithmetic with NumPy Arrays:
import numpy as np
arr1 = np.random.randint(1, 10, size=(2,2))
arr2 = np.random.randint(1, 10, size=(2,2))
result = np.dot(arr1, arr2)
print(result)
Creating ndarrays: Question: Create a 3x3 numpy array with random integers between 1 and 10.
Creating ndarrays:
Output:
Data Types for ndarrays: Question: Create a numpy array with the following data types: integer, float, string, boolean, and complex.
Data Types for ndarrays:
Output:
Arithmetic with NumPy Arrays: Question: Create two numpy arrays of shape (2,2) with random integers between 1 and 10. Perform matrix multiplication between the two arrays and return the result.
Arithmetic with NumPy Arrays:
Output:
creating array