Final NumPy Assessment
Welcome to the final NumPy assessment at CIIT TRANING INSTITUTE. This assessment evaluates your understanding of NumPy arrays, array creation, indexing, slicing, data types, reshaping, broadcasting, mathematical functions, filtering, sorting, random number generation, linear algebra, and file operations. Attempt the questions independently before checking the answers and solutions.
Assessment Instructions
- Read each question carefully before answering.
- Use Python and NumPy to test your answers where appropriate.
- For output-based questions, predict the result before running the code.
- For coding questions, write a complete and readable solution.
- Try to complete the assessment before reviewing the answer key.
Suggested duration: 60–90 minutes.
Total marks: 100.
Section A: Multiple-Choice Questions
10 questions × 2 marks = 20 marks
Question 1
Which function creates an array containing a sequence of integers?
- A.
np.array_range() - B.
np.arange() - C.
np.sequence() - D.
np.integer_array()
Question 2
What is the shape of the following array?
- A.
(6,) - B.
(3, 2) - C.
(2, 3) - D.
(2, 2)
Question 3
Which expression selects the second column of a two-dimensional array named data?
- A.
data[1, :] - B.
data[:, 1] - C.
data[2, :] - D.
data[1, 1]
Question 4
Which attribute returns the total number of elements in an array?
- A.
shape - B.
ndim - C.
size - D.
dtype
Question 5
Which function returns unique values from an array?
- A.
np.distinct() - B.
np.unique() - C.
np.remove_duplicates() - D.
np.different()
Question 6
What does axis=0 do when used with sum() on a two-dimensional array?
- A. Calculates a sum for each row.
- B. Calculates a sum for each column.
- C. Returns only the first element.
- D. Reshapes the array.
Question 7
Which operator performs element-wise multiplication of two compatible arrays?
- A.
* - B.
@ - C.
** - D.
//
Question 8
Which function is commonly used to solve a suitable square system of linear equations?
- A.
np.linalg.sort() - B.
np.linalg.solve() - C.
np.linalg.reshape() - D.
np.linalg.random()
Question 9
Which method is recommended for creating a modern NumPy random generator?
- A.
np.random.default_rng() - B.
np.random.create_array() - C.
np.generator.seed_array() - D.
np.random.make_random()
Question 10
Which NumPy file format is intended for saving a single array in binary format?
- A.
.txt - B.
.csv - C.
.npy - D.
.html
Section B: Predict the Output
5 questions × 4 marks = 20 marks
Question 11: Array Slicing
Your task: Predict the output.
Answer:
Question 12: Reshaping
Answer:
Question 13: Boolean Filtering
Answer:
Question 14: Broadcasting
Answer:
Question 15: Aggregation
Answer:
Section C: Practical Coding Questions
5 questions × 6 marks = 30 marks
Question 16: Create and Inspect an Array
Create a 3 × 3 array containing integers from 1 to 9. Display its shape, dimensions, size, and data type.
Solution:
Expected output:
The displayed integer data type may differ depending on the platform and NumPy's type selection.
Question 17: Analyze Student Marks
Create a marks array for Samadhan, Pradnya, and Samiksha. Calculate each student's total and average, and identify students whose average is at least 80.
Solution:
Expected output:
Question 18: Filter and Replace Values
Replace negative values with zero and select all values greater than 10.
Solution:
Expected output:
Question 19: Sort Sales Values
Sort sales in descending order and identify the maximum sale.
Solution:
Expected output:
Question 20: Perform Matrix Multiplication
Multiply the two matrices and display the result.
Solution:
Expected output:
Section D: Advanced Application Questions
3 questions × 10 marks = 30 marks
Question 21: Sales Report Analysis
Given a matrix of monthly sales for three products:
- Calculate the total sales for each product.
- Calculate the total sales for each month.
- Identify the product with the highest total sales.
- Identify the month with the highest total sales.
Solution:
Expected output:
Question 22: Normalize a Dataset
Normalize the following values using min-max normalization:
Use the formula:
(value - minimum) / (maximum - minimum)
Solution:
Expected output:
In reusable code, handle the case where the minimum and maximum are equal to avoid division by zero.
Question 23: Solve a Linear System
Solve the equations:
2x + y = 8
x + 3y = 9
Solution:
Expected output:
Answer Key: Section A
| Question | Correct answer | Explanation |
|---|---|---|
| 1 | B — np.arange() |
Creates values in a specified numerical range. |
| 2 | C — (2, 3) |
The array has two rows and three columns. |
| 3 | B — data[:, 1] |
Selects all rows from the second column. |
| 4 | C — size |
Returns the total number of elements. |
| 5 | B — np.unique() |
Returns the distinct values. |
| 6 | B — Each column | axis=0 reduces across rows. |
| 7 | A — * |
Performs element-wise multiplication. |
| 8 | B — np.linalg.solve() |
Solves suitable linear systems. |
| 9 | A — np.random.default_rng() |
Creates a modern random generator. |
| 10 | C — .npy |
Stores a single NumPy array in binary format. |
Suggested Evaluation Rubric
| Section | Marks | Skills evaluated |
|---|---|---|
| A. Multiple choice | 20 | Core NumPy concepts and terminology. |
| B. Predict the output | 20 | Indexing, slicing, broadcasting, and aggregation. |
| C. Practical coding | 30 | Correct implementation and output. |
| D. Advanced applications | 30 | Problem-solving, numerical reasoning, and analysis. |
| Total | 100 | Overall NumPy proficiency. |
Suggested Performance Bands
- 90–100: Excellent — strong command of NumPy fundamentals and applications.
- 75–89: Very good — capable of solving most practical NumPy problems.
- 60–74: Good — review advanced indexing, axes, and broadcasting.
- 40–59: Developing — revisit array creation, indexing, and core operations.
- Below 40: More practice recommended before moving to advanced projects.
These performance bands are suggested learning guidelines. The institute can adjust them to match its own assessment policy.
Summary
This final assessment reviewed NumPy array creation, indexing, slicing, attributes, Boolean filtering, broadcasting, aggregation, sorting, vectorization, normalization, matrix multiplication, linear algebra, and practical data analysis.
Review any incorrect answers, rerun the coding exercises, and practice applying NumPy to real datasets. Completing this assessment provides a foundation for using NumPy in data analysis, scientific computing, machine learning preparation, and numerical programming projects.