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

PWP Practical 13 PDF

This document provides guidelines for writing practical write-ups and contains 3 programs demonstrating the use of built-in and user-defined packages in Python. The first program performs matrix operations using the NumPy package. The second program concatenates two strings using NumPy functions. The third program generates random integers between 10-30 using NumPy.

Uploaded by

pruthviraj patil
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)
534 views

PWP Practical 13 PDF

This document provides guidelines for writing practical write-ups and contains 3 programs demonstrating the use of built-in and user-defined packages in Python. The first program performs matrix operations using the NumPy package. The second program concatenates two strings using NumPy functions. The third program generates random integers between 10-30 using NumPy.

Uploaded by

pruthviraj patil
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

Practical No.

13

GUIDELINES FOR WRITING THE PRACTICAL WRITEUP

1. Use ruled file pages for write-up of practical contents.


2. You can use both side ruled pages for the same.
3. Start each practical (experiment) write-up on new page.
4. Maintain all these practical work in a file as it will be considered for
TW (continuous assessment) of the course PWP.
5. Write question answers given and take print out of only programs or
can write it on assignment pages.
6. Complete the practical write-up in time. Don’t keep it pending.

Practical No. 13 : Write Python program to demonstrate use of Built-in Package


and User Defined Package.

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.

2. What is Numpy Array?

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.

(***** Run the below programs in Google Colab)


Practical No. 13

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


addition, subtraction, multiplication, division operation on
matrix.

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

2. Write a python program to concatenate two strings.


import numpy as np

print("Concatenating two strings: ")

print(np.char.add('Hello','World'))

Output:
Concatenating two strings:
HelloWorld

3. Write numpy program to generate six random integers


between 10 and 30.
import numpy as np

random_array=np.random.randint(low=10,high=30,size=6)

print("Six random integers between 10 and 30 are ", random_array)

Output:
Six random integers between 10 and 30 are [24 25 19 21 23 26]

You might also like