Gramin Technical and Management Campus
Department of computer engineering
Subject/code: -Python/22616
Name:-Pranusha Shiddhodhan Birhade
DOP: DOS:-
Practical No 13
1) Write a Python program to create two matrices and perform
addition, subtraction, multiplication and division operation on
matrix.
Code:-
import numpy as np
def main():
print("Enter the elements of the first matrix (e.g., 1 2; 3 4):")
A = [Link]([list(map(float, [Link]())) for row in input().split(';')])
print("Enter the elements of the second matrix (e.g., 5 6; 7 8):")
B = [Link]([list(map(float, [Link]())) for row in input().split(';')])
print("\nMatrix A:")
print(A)
print("\nMatrix B:")
print(B)
print("\nAddition of A and B:")
print(A + B)
print("\nSubtraction of A and B:")
print(A - B)
print("\nMultiplication of A and B:")
print(A * B) print("\nDivision of A by B:")
print(A / B)
if __name__ == "__main__":
main()
Output:-
2) Write a Python program to concatenate two strings
Code:-
def concatenate_strings(str1, str2):
return str1 + str2
if __name__ == "__main__":
string1 = input("Enter the first string: ")
string2 = input("Enter the second string: ")
result = concatenate_strings(string1, string2)
print("Concatenated String:", result)
Output:-
3) Write a NumPy program to generate six random integers between 10
and 30.
Code:-
import numpy as np
random_integers = [Link](10, 31, size=6)
print("Six random integers between 10 and 30:", random_integers)
Output:-