# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

import numpy as np

l=[1,2,3,4]

np.asarray(l)

np.zeros(5)

np.zeros((2,3,4))

np.ones(4)

np.ones((3,4,5))

np.zeros((4,5))+5

np.empty((2,4)) #generate random values which are very small

np.linspace(4,6) #generates no between starting point and end point. default is 50 nos

np.linspace(2,6,40)

np.linspace(2,6,10).reshape(2,5)

np.linspace(2,6,10,endpoint=False) #does not include the last no

np.linspace(2,6,endpoint=False, retstep=False)

np.logspace(2,4,10,base=10) #generate an array of log values

a=np.arange(16).reshape(4,4)
a

a.max()

b=np.arange(4,40).reshape(6,6)
b

b.max(axis=0) #row wise comparison

b.max(axis=1) #column wise comparison

b

a=np.array([1,2,3,1,2,3])
a

a+b

a.T

a=a.reshape(1,-1)
a

a.T

a+b

np.sqrt(b)

np.exp(b)

np.log10(b)

x=np.array([1,2,3])
x

y=x #shallow copy - any change in x will reflect in y
y

z=np.copy(x) #deep copy - any change in x will not reflect in z
z

x[0]=100
x

# +
y #y is reffering to the same memory location as x 

#any change in x will reflect in y also (y=x)
# -

z

id(x) #returns the identity of object

id(y)

id(z)

id(x[0])

id(y[0])

id(x[0])==id(y[0]) #id(x) and id(y) is different but still it is giving true

id(x)==id(z)



StarcoderdataJupyterScriptsDedupFiltered