0% found this document useful (0 votes)
13 views2 pages

Q1: Array Creation & Basic Operations

The document outlines a series of tasks involving NumPy arrays, including creating and reshaping arrays, performing indexing and slicing, applying boolean masking, utilizing broadcasting for mathematical operations, and generating random matrices. It specifies operations such as summing rows and columns, extracting and modifying elements, and calculating statistical measures. Additionally, it includes instructions for normalizing a matrix using a specific formula.

Uploaded by

albiinnn5
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)
13 views2 pages

Q1: Array Creation & Basic Operations

The document outlines a series of tasks involving NumPy arrays, including creating and reshaping arrays, performing indexing and slicing, applying boolean masking, utilizing broadcasting for mathematical operations, and generating random matrices. It specifies operations such as summing rows and columns, extracting and modifying elements, and calculating statistical measures. Additionally, it includes instructions for normalizing a matrix using a specific formula.

Uploaded by

albiinnn5
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/ 2

Q1: Array Creation & Basic Operations

Create a 4x4 NumPy array with values from 1 to 16.


• Reshape it into a 2D matrix.
• Find the sum of each row and sum of each column.

Q2: Indexing & Slicing


Given the array:
arr = np.array([10, 20, 30, 40, 50, 60, 70])
• Extract elements from index 2 to 5.
• Replace all even numbers with -1.

Q3: Boolean Masking


Given the array:
arr = np.array([15, 23, 8, 42, 4, 16, 9])
• Find all numbers greater than 10 and divisible by 2.
• Replace those numbers with 0.

Q4: Broadcasting & Mathematical Operations


Create a 1D array a = np.array([1, 2, 3]) and a 2D array
b = np.array([[10], [20], [30]])
• Use broadcasting to add them together.
• Compute the element-wise multiplication without using a loop.
Q5: Statistics & Random Numbers
• Generate a random 5x5 matrix with values between 0 and 1.
• Find the mean, median, variance, and standard deviation.
• Normalize the matrix (scale values between 0 and 1).
Normalize (0 to 1 scaling) use this equation
norm = (matrix - np.min(matrix)) / (np.max(matrix) - np.min(matrix))

You might also like