Phython Practical Notebook
Phython Practical Notebook
Phython Practical Notebook
Code-
Import numpy as np
Ones=np.ones((2,3))
Print(“Array of all ones:\n”,ones)
Zeros=np.zeros((2,3))
Print(“Array of all zeros:\n”,zeros)
random=np.random.random((2,3))
print(“Array of random elements:\n”,random)
output:
Page |3
Code –
import numpy as np
arr=np.array([[2,3,4],[4,6,8],[8,0,1]])
a=int(input(“enter the row you want to delete”))
arr1=np.delete(arr,a,0)
print(“Your original array:\n”,arr)
print(“Your array after deleting the row:\n”,arr1)
output:
Page |4
#3x3 matrix
X= [ [ 12,7,3],
[4, 5, 6],
[7 ,8 ,9] ]
# 3x4 matrix
Y= [ [5,8,1,2],
[6,7,3,0],
[4,5,9,1] ]
# result is 3x4
Result = [[0,0,0,0],
[0,0,0,0],
[0,0,0,0]]
output:
Page |8
import numpy as np
matrix =np.array([[1,2,3],[4,5,6],[7,8,9]])
print(“Matrix:\n’’,matrix)
print(“Matrix norm:”,np.linalg.norm(matrix)
output:
Page |9
# printing eigenvalues
Print(“Printing the eigen values of the given square array:\n”,w)
Output:
P a g e | 11
def plot_regression_line(x,y,b):
P a g e | 12
# putting labels
Plt.xlabel(‘x’)
Plt.ylabel(‘y’)
Def main() :
# observation / data
X = np.array ( [ 0,1,2,3,4,5,6,7,8,9 ] )
Y = np.array ( [ 1,3,2,5,7,8,8,9,10,12]
output:
P a g e | 14
output: