- Get link
- X
- Other Apps
# In[1]: import numpy as np # In[2]: # Array of ones using matrix array_of_ones = np.ones((3,4)) # (3,4) is (x,y) where x is no of rows and y is no of cols array_of_ones # In[13]: # How to specify te data type? # We use dtype function array_of_ones_int = np.ones((4,5),dtype=np.int16) array_of_ones_int # In[15]: #Or array_of_ones_int = np.ones((4,5),dtype=int) array_of_ones_int # In[16]: array_of_ones_bool = np.ones((4,5),dtype=bool) array_of_ones_bool # In[18]: array_of_ones_str = np.ones((3,5),dtype=str) array_of_ones_str # In[19]: array_of_ones_float = np.ones((3,5),dtype=float) array_of_ones_float # In[20]: array_of_ones_float1 = np.ones((3,5)) # By default it gives a float value, without declaring the data type array_of_ones_float1 # In[21]: array_empty = np.empty((2,3)) array_empty # In[22]: # How to create identity matrix #np.eye() array_eye = np.eye(3) array_eye # In[23]: # range is in Python # ar...