Skip to content

NumPy – Student Marks AnalysisΒ #29

Description

@asifmohammed1

🎯 Objective

You are given the marks of 10 students. Use NumPy to perform different operations and analyze the data.

This project covers the most important NumPy topics:

  • Creating Arrays
  • Array Properties (shape, size, ndim, dtype)
  • Indexing & Slicing
  • reshape()
  • Arithmetic Operations
  • Aggregate Functions
  • Boolean Indexing
  • Matrix Operations
  • Random Numbers

Starter Code

import numpy as np

marks = np.array([75, 82, 90, 68, 55, 79, 88, 95, 60, 72])

Tasks

1. Display the Marks

Print the complete marks array.


2. Check Array Properties

Print:

  • Number of dimensions
  • Shape
  • Size
  • Data type

3. Indexing & Slicing

  • Print the first student's marks.
  • Print the last student's marks.
  • Print marks from index 2 to index 6.
  • Print the first five students' marks.

4. Reshape the Array

Convert the 1D array into a 2 Γ— 5 matrix.

Example:

[[75 82 90 68 55]
 [79 88 95 60 72]]

5. Arithmetic Operations

Add 5 grace marks to every student.

Then multiply every mark by 2.


6. Aggregate Functions

Find:

  • Total marks
  • Average marks
  • Highest marks
  • Lowest marks
  • Standard deviation

7. Boolean Indexing

Display:

  • Students scoring above 80.
  • Students scoring below 70.

8. Matrix Operations

Using the reshaped (2 Γ— 5) array:

  • Print its transpose.

9. Random Numbers

Generate marks for 5 new students between 50 and 100 using NumPy.

Example Output:

[65 91 73 88 56]

10. Bonus Challenge

Answer the following:

  1. How many students scored above 75?
  2. How many students failed (marks below 35)?
  3. Find the topper's marks.
  4. Find the average marks of students scoring above 70.
  5. Replace all marks below 60 with 60.
  6. Sort the marks in ascending order.

Expected Skills Covered

  • βœ… np.array()
  • βœ… shape
  • βœ… size
  • βœ… ndim
  • βœ… dtype
  • βœ… Indexing & Slicing
  • βœ… reshape()
  • βœ… Arithmetic Operations
  • βœ… sum()
  • βœ… mean()
  • βœ… max()
  • βœ… min()
  • βœ… std()
  • βœ… Boolean Indexing
  • βœ… transpose()
  • βœ… np.random.randint()
  • βœ… np.sort()

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions