Join WhatsApp Group Join Now!

Basic of Python Programming (313011) Practical No.15: Develop Python program to demonstrate use of NumPy package for creating, accessing and performing different array operations

Basic of Python Programming (313011) Practical No.15: Develop Python program to demonstrate use of NumPy package for creating, accessing and performin
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 Basic of Python Programming (313011) Practical No.15: Develop Python program to demonstrate use of NumPy package for creating, accessing and performing different array operations

NumPy can be used to perform a wide variety of mathematical operations on arrays. It adds powerful data structures to Python that guarantee efficient calculations with arrays and matrices and it supplies an enormous library of high- level mathematical functions that operate on these arrays and matrices.

Basic of Python Programming (313011)

Practical related Questions

1. Write the output of the following program.

import numpy as np
arr = np.zeros((2, 3),dtype=float) # 2 rows and 3 columns
print (arr)

Answer:

[[0. 0. 0.]
 [0. 0. 0.]]

2. Write the output of the following program.
import numpy as np
arr = np.random.random((3, 3)) # 3 rows and 3 columns
print (arr)

Answer:

[[0.84556229 0.43172942 0.44085081]
 [0.52778292 0.80677987 0.67786648]
 [0.63301872 0.32068272 0.23648907]]

3. Insert the correct method for creating a NumPy array.
arr = np. ([1, 2, 3, 4, 5])

Answer: 

import numpy as np

arr = np.array([1, 2, 3, 4, 5])

Exercise

1. Write a Python NumPy program to create a 3x3 identity matrix.

Answer:

import numpy as np

# Create a 3x3 identity matrix
identity_matrix = np.identity(3)

# Print the matrix
print("3x3 Identity Matrix:")
print(identity_matrix)


2. Write a Python NumPy program to create a 4x4 matrix with values ranging from 2 to
10.

Answer:

import numpy as np

# Create a 4x4 matrix with values ranging from 2 to 10
matrix = np.arange(2, 18).reshape(4, 4)

# Print the matrix
print("4x4 Matrix with values ranging from 2 to 17:")
print(matrix)




Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.