Experiment No 11
Experiment No 11
Roll No: 54
Batch: B3
Date: 25/03/25
Addition:
import numpy as np
first_array = np.array([1, 3, 5, 7])
second_array = np.array([2, 4, 6, 8])
# using the + operator
result1 = first_array + second_array
print("Using the + operator:",result1)
# using the add() function
result2 = np.add(first_array, second_array)
print("Using the add() function:",result2)
Output:-
Subtraction:
import numpy as np
first_array = np.array([3, 9, 27, 81])
second_array = np.array([2, 4, 8, 16])
# using the - operator
result1 = first_array - second_array
print("Using the - operator:",result1)
# using the subtract() function
result2 = np.subtract(first_array, second_array)
print("Using the subtract() function:",result2)
Output:-
Multiplication:
import numpy as np
first_array = np.array([1, 3, 5, 7])
second_array = np.array([2, 4, 6, 8])
# using the * operator
result1 = first_array * second_array
print("Using the * operator:",result1)
# using the multiply() function
result2 = np.multiply(first_array, second_array)
print("Using the multiply() function:",result2)
Output:-
Division:
import numpy as np
first_array = np.array([1, 2, 3])
second_array = np.array([4, 5, 6])
# using the / operator
result1 = first_array / second_array
print("Using the / operator:",result1)
# using the divide() function
result2 = np.divide(first_array, second_array)
print("Using the divide() function:",result2)
Output:-
Power:
import numpy as np
array1 = np.array([1, 2, 3])
# using the ** operator
result1 = array1 ** 2
print("Using the ** operator:",result1)
# using the power() function
result2 = np.power(array1, 2)
print("Using the power() function:",result2)
Output:-
Mod:
import numpy as np
first_array = np.array([9, 10, 20])
second_array = np.array([2, 5, 7])
# using the % operator
result1 = first_array % second_array
print("Using the % operator:",result1)
# using the mod() function
result2 = np.mod(first_array, second_array)
print("Using the mod() function:",result2)
Output:-
Output:-
Output:-