0% found this document useful (0 votes)
0 views

Python pr.no.13

The document provides Python code examples for performing matrix operations such as addition, subtraction, multiplication, and division using NumPy. It also includes a simple string concatenation example and a program to generate six random integers between 10 and 30. Each code snippet is followed by its expected output.

Uploaded by

trushnaanantwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Python pr.no.13

The document provides Python code examples for performing matrix operations such as addition, subtraction, multiplication, and division using NumPy. It also includes a simple string concatenation example and a program to generate six random integers between 10 and 30. Each code snippet is followed by its expected output.

Uploaded by

trushnaanantwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No:13

1. Write a Python program to create two matrices and perform


addition,
subtraction, and multiplication and division operation on matrix.

Code:
import numpy
x=numpy.array([[1,2],[4,5]])
y=numpy.array([[7,8],[9,10]])
print("Addition of 2 matrix",numpy.add(x,y))
print("Substration of 2 matrix",numpy.subtract(x,y)) print("multiply
of 2
matrix",numpy.multiply(x,y)) print("Divictiom of 2
matrix",numpy.divide(x,y))

Output:

2. Write a Python program to concatenate two strings.


str1="Hello"
str2="Good Morning"
str3=str1+ str2
print(str3)

Output:
13.3. Write a NumPy program to generate six random integers
between 10
and 30.

import numpy as np
x=np.random.randint(low=10,high=30,size=6)
print(x)

Output:

You might also like