Arrays
Arrays
NumPy package
Numerical python
Advanced computing in pythonLinear
algebra,Fourier transform
Usually imported as np
Import numpy as np
To install numpy
Type in terminal
pip install numpy
or
pip3 install numpy
Any module can be imported with
another name
import math as ma
a=ma.sqrt(9)
print(a)
ARRAYS
output
[1 2 3 4 5 6]
import numpy as n1
ar1=n1.array([1,2,3,4,5,6])
print(ar1)
MATRICES USING ARRAYS
import numpy as np
mat1=np.array([[1,2,3],
[4,5,6]])
print(mat1)
ARRAY DIMENSIONS
Size
across
each
dimension-
shape
ACCESSING
ARRAY
ELEMENTS
For loop
to
traverse
array
reshapin
g
MATRIX OPERATIONS-ADDITION,
MULTIPLICATION ,SUBTRACTION
SIZES OF MATRICES-SHOUL BE COMPATIBLE FOR
ADDITION,SUBTRACTION & MULTIPLICATION-ELSE ERROR