0% found this document useful (0 votes)
12 views3 pages

Python Pra13

The document contains practical exercises for a Python course, including programs for matrix operations (addition, subtraction, multiplication, and division), string concatenation, and generating random integers using NumPy. It provides code snippets for each task along with sample input and output. The exercises aim to enhance programming skills in Python and familiarity with the NumPy library.

Uploaded by

birhadepranusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Python Pra13

The document contains practical exercises for a Python course, including programs for matrix operations (addition, subtraction, multiplication, and division), string concatenation, and generating random integers using NumPy. It provides code snippets for each task along with sample input and output. The exercises aim to enhance programming skills in Python and familiarity with the NumPy library.

Uploaded by

birhadepranusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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 = np.array([list(map(float, row.split())) for row in input().split(';')])

print("Enter the elements of the second matrix (e.g., 5 6; 7 8):")

B = np.array([list(map(float, row.split())) 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 = np.random.randint(10, 31, size=6)

print("Six random integers between 10 and 30:", random_integers)

Output:-

You might also like