<jupyter_start><jupyter_text>Numpy<jupyter_code>l1=[  # It is 3D array list
    [
        [1,1,1],
        [2,2,2]
    ],
    [
        [3,3,3],
        [4,4,4]
    ]
]
l2= l1.copy()
r = []
print( l1[0][1][1] )
# We trying to add two matrices using loops
print(l1)
print(l2)
print(len(l1))
for row in range(len(l1)):
    r1 = []
    for inner_row in range(len(l1[0])):
        c = []
        for col in range(len(l1[0][0])):
            s = l1[row][inner_row][col] + l2[row][inner_row][col]
            c.append(s)
        r1.append(c)
    r.append(r1)
print(r)
import numpy as np
# create of array
l1=[1,2,3,4]
l2=[4,5,6,7]
a1=np.array(l1)
a2=np.array(l2)
s1=a1+a2  # It add each element with-respect 
s2=l1+l2  # It append list
print('a1 :',a1)
print('a2 :',a2)
print('l1 :',l1)
print('l2 :',l2)
print('s1=a1+a2 :',s1)
print('s2=l1+l2 :',s2)
print('type of a1 : ',type(a1))
print('type of l1 : ',type(l1))
print()
print(dir(np))
# Now we add l1 and l2 which we trying to add by for loop in upper cells
arr_l1 = np.array([l1])
arr_l2 = np.array([l2])
su = arr_l1 + arr_l2
print(su)
a=np.arange(1,101)
print(a)
print(a.size) # this
print(len(a))
# If we want to create two D matrices
b = a.reshape(10,10)
print(b)
print(a.mean())  # In build function
print(np.mean(a))
print(np.median(a))
b.transpose()

x=np.linspace(1,10,20)
print(x)
print(x.size)
print(x[5])


k = np.zeros(12)
print(k)

k = np.zeros((6,5)) # two d array 6 row 5 column
print(k)

k = np.ones(12)
print(k)

np.zeros((2,4),dtype=float)
l = [1,2,3,1]
k = np.identity(4,dtype=int) # its take only integer values not a list
print(k)
k = np.random.normal(20,5,500)  # [20 mean ] [5 deviation  range is between 15-25] [ 5] no printed

from matplotlib import pyplot as plt
plt.plot((k) )
plt.show()<jupyter_output><empty_output><jupyter_text>Math Operations1. Sum2. Prod<jupyter_code>#sum(value , axis = 0,1,None) o means row vise and 1 means column vise and none means overall sum
import numpy as np
ar1 = np.array([[1,2],[3,4]])
print(ar1)
print()
print(np.sum(ar1,axis = 0 , keepdims=True))  # 0 means row wise sum is calculated of all rows 
print()
print(np.prod(ar1,axis = 1 , keepdims=True))

import numpy as np

nm=list(map(int,input().split()))
a=[]
for i in range(nm[0]):
    a.append(list(map(int,input().split())))
s = np.sum(a , axis = 0)
print(np.prod(s))<jupyter_output><empty_output><jupyter_text>DOT CROSS PRODUCT<jupyter_code>import numpy as np
n  = int(input())
o = []
t = []
for i in range(2):
    if i==0:
        for j in range(n):
            o.append(list(map(int,input().split())))
    elif i==1:
        for j in range(n):
            t.append(list(map(int,input().split())))
o = np.array(o)
t = np.array(t)
print(np.dot(o,t))<jupyter_output><empty_output><jupyter_text>Inner and Outer product<jupyter_code>np.random.seed(100)
a = np.array([[[1,4]],[[5,6]]])
qq1 = np.array([[1,1],
                [2,2],
                [3,3]])  # 3,2

qq2 = np.array([[1,3],
                [2,4],
                [3,5],
                [10,10],
                [20,20]])  # 5,2

print(np.inner(qq1,qq2))  #j second dimension must be same size

print()

print(np.outer(qq1,qq2))  # 3,2 = 6  5,2 = 10  6,10 matrix of output array
print(o)
o2 = o.copy()

print(np.inner(o,o2))
print(np.outer(o,o2))
import numpy as np
o  = np.array(list(map(int,input().split())))
t  = np.array(list(map(int,input().split())))
print(np.inner(o,t)) # column wise multiplication and then add them
print(np.outer(o,t))<jupyter_output><empty_output><jupyter_text>Polynomial1. ploy2. roots3. polyint4. polyder5. polyadd6. polyval7. polyfit8. polysub9. polymul10. polydiv<jupyter_code>print(np.poly([0,-2])) #   [z**2 + 2*z**1 + 0 =root] = [0 ,-2] we are passing roots it return coefficent  of  a  function
print(np.roots([1,2,0]))
print()
print(np.polyint([1,1,1])) # antiderivate
print(np.polyder([1,2,0,4])) # derivative
print(np.polyval([0,-2],1)) # evaluate value at specified
print(np.polyfit([1,2,3,3,1],[1,2,2,3,4],2))

import numpy as np
l = list(map(int , input().split()))
print(np.zeros(l , dtype=int))
print(np.ones(l , dtype=int))

# Identity
print(np.identity(3)) # square matrix forming

# eye  (print 1 as a diagonal k=1 is upper shift k=-1 lower shift k=0 default)
print(np.eye(3,5))
print()
print(np.eye(3,5 , k=2))

print(np.eye(3,4,k=1))
print()
print(np.eye(3,4,k=-1))
import numpy as np
a,b = input().split()
print(np.eye(int(a) , int(b) , k = 0))
import numpy
(numpy.eye(*map(int,input().split())))
import numpy
print(str(numpy.eye(*map(int,input().split()))).replace('1',' 5').replace('0',' 0'))
import numpy as np
a = np.array([1,2,3,4] , float)
b = np.array([5,6,7,8] , float)
print(a+b)
print(np.add(a,b))
print(np.multiply(a,b))
print(np.divide(a,b))
print(np.power(a,b))
print(np.mod(a,b))
import numpy
a , b = list(map(int , input().split()))
la = numpy.array(list(map(int , input().split())))
lb = numpy.array(list(map(int , input().split())))
print(numpy.add(la,lb))
print(numpy.subtract(la,lb))
print(numpy.multiply(la,lb))
print(numpy.divmod(la,lb)[0])
print(numpy.mod(la,lb))
print(numpy.power(la,lb))
import numpy as np
n, m = map(int, input().split())
a, b = (np.array([input().split() for _ in range(n)], dtype=int) for _ in range(2))
print(a+b, a-b, a*b, a//b, a%b, a**b, sep='\n')
import numpy

my_array = numpy.array([[2, 5], 
                        [3, 7],
                        [1, 3],
                        [4, 0]])

print (numpy.min(my_array, axis = 0))         #Output : [1 0]
print (numpy.min(my_array, axis = 1))         #Output : [2 3 1 0]
print (numpy.min(my_array, axis = None))      #Output : 0
print (numpy.min(my_array))                   #Output : 0
import numpy

my_array = numpy.array([[2, 5], 
                        [3, 7],
                        [1, 3],
                        [4, 0]])

print (numpy.max(my_array, axis = 0))         #Output : [4 7]
print (numpy.max(my_array, axis = 1) )        #Output : [5 7 3 4]
print (numpy.max(my_array, axis = None))      #Output : 7
print (numpy.max(my_array))                   #Output : 7
n , m = map(int , input().split())
l = []
for i in range(n):
        l.append(min(list(map(int , input().split()))))
print(max(l))<jupyter_output><empty_output><jupyter_text>1. Mean2. Varience3. Standard Deviation<jupyter_code>import numpy

my_array = numpy.array([ [1, 2], [3, 4] , [5, 6]])

print (numpy.mean(my_array, axis = 0))        #Output : [ 3.  4.] column wise
print (numpy.mean(my_array, axis = 1))        #Output : [ 1.5  3.5 5.5] row wise
print (numpy.mean(my_array, axis = None))     #Output : 2.5
print (numpy.mean(my_array))                  #Output : 2.5
import numpy

my_array = numpy.array([ [1, 2], [3, 4] ])

print (numpy.var(my_array, axis = 0))         #Output : [ 1.  1.]
print (numpy.var(my_array, axis = 1))         #Output : [ 0.25  0.25]
print (numpy.var(my_array, axis = None))      #Output : 1.25
print (numpy.var(my_array))                   #Output : 1.25
import numpy

my_array = numpy.array([ [1, 2], [3, 4] ])

print (numpy.std(my_array, axis = 0))         #Output : [ 1.  1.]
print (numpy.std(my_array, axis = 1))         #Output : [ 0.5  0.5]
print (numpy.std(my_array, axis = None))      #Output : 1.11803398875
print (numpy.std(my_array))                   #Output : 1.11803398875
The mean along axis 1
The var along axis 0
The std along axis None


import numpy
n , m = map(int , input().split())
l = []
for i in range(n):
        l.append((list(map(int , input().split()))))

l = numpy.array(l)
numpy.set_printoptions(legacy='1.13')
print(numpy.mean(l , axis=1))
print(numpy.var(l , axis=0))
print(numpy.std(l , axis=None))
n = np.array([input().split() for _ in range(int(input().split()[0]))],int)
print(np.mean(n,axis=1),np.var(n,axis=0),np.std(n),sep="\n")
import numpy

arr = numpy.array([[int(i) for i in input().split()] for _ in range(int(input()[0]))])
print(numpy.mean(arr, axis = 1), numpy.var(arr, axis = 0), numpy.std(arr), sep = "\n")<jupyter_output><empty_output><jupyter_text>Linear Algebra<jupyter_code># Linear Algebra
print (numpy.linalg.det([[1 , 2], [3, 4]]))       #Output : -2.0  compute deerminant of array
vals, vecs = numpy.linalg.eig([[1 , 2], [2, 1]])  # compute eignvalues
print (vals)                                      #Output : [ 3. -1.]
print( vecs )                                     #Output : [[ 0.70710678 -0.70710678]
                                                #          [ 0.70710678  0.70710678]]
print (numpy.linalg.inv([[1 , 2], [2, 1]]))       #Output : [[-0.33333333  0.66666667]  multiplicative inverse
#numpy.set_printoptions(legacy='1.13')  #          [ 0.66666667 -0.33333333]]<jupyter_output><empty_output><jupyter_text>1. Floor2. ceil3. rent<jupyter_code>import numpy
l = numpy.array(input().split() , float)
l = [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]
print(numpy.floor(l)) # toward positive
print(numpy.ceil(l)) # jis direction m jara h uski floor value
print(numpy.rint(l)) #jis direction m jara h uski round off value
print(np.trunc(l))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19523017193566278, 'fraction_numerical': 0.05612867443150305, 'mean_word_length': 3.2912898619704904, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '159214', 'license': 'Apache-2.0', 'n_tokens_mistral': 3908, 'n_tokens_neox': 3700, 'n_words': 836, 'path': '.ipynb_checkpoints/01. Numpy-checkpoint.ipynb', 'repo_name': 'Girrajjangid/Python-Beginner-to-Advance', 'size': '9015'}