Professional Documents
Culture Documents
13
1. What is a package?
Ans:
A python package is a collection of modules which have a common purpose.
i.e modules are grouped together to form package.
Ans:
A numpy array is a grid of values, all of the same type, and is indexed by a tuple of
nonnegative integers. The number of dimensions is the rank of the array; the shape
of an array is a tuple of integers giving the size of the array along each dimension.
import numpy as np
matrix1=np.array([[1,2,3],[22,86,19]])
matrix2=np.array([[7,8,9],[4,5,6]])
print("Addition of two matrices is \n",matrix1+matrix2)
print("Subtraction of two matrices is \n",matrix1-matrix2)
print("Multiplication of two matrices is \n",matrix1*matrix2)
print("Division of two matrices is \n",matrix1//matrix2)
Output:
Addition of two matrices is
[[ 8 10 12]
[26 91 25]]
Subtraction of two matrices is
[[-6 -6 -6]
[18 81 13]]
Multiplication of two matrices is
[[ 7 16 27]
[ 88 430 114]]
Division of two matrices is
[[ 0 0 0]
[ 5 17 3]]
Practical No. 13
print(np.char.add('Hello','World'))
Output:
Concatenating two strings:
HelloWorld
random_array=np.random.randint(low=10,high=30,size=6)
Output:
Six random integers between 10 and 30 are [24 25 19 21 23 26]