NumPy is a python package used for numerical and scientific computing. It provides better runtime and space complexity. NumPy arrays are faster and more compact than Python lists. An array consumes less memory and is convenient to use. NumPy uses much less memory to store data and it provides a mechanism of specifying the data types.
It provides a wide variety of array operations. If you wish to perform general-purpose operations, use python lists.
Numpy part II Link: • 49. NumPy Datatypes in Python with Co...
Numpy part III Link: • 50. NumPy Array Indexing in Python wi...
Numpy part IV Link: • 51. NumPy Array Math in Python with C...
Numpy part V Link: • 52. NumPy Arrays Reorganizing Functio...
Code:
import numpy as np
x=np.arange(2,6).reshape(4)
print(x)
x2=np.arange(2,10).reshape(2,4)
print(x2)
x3=np.arange(24).reshape(4,3,2)
print(x3)
mylist=[1,2,3,4]
numpyArrayFromList=np.array(mylist)
print(numpyArrayFromList)
myList2=np.array(range(1,5))
print(myList2)
a=np.array([1,2,3])
print(type(a))
myMatrix=[[1,2,3],[4,5,6],[7,8,9]]
print(myMatrix)