π― 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:
9. Random Numbers
Generate marks for 5 new students between 50 and 100 using NumPy.
Example Output:
10. Bonus Challenge
Answer the following:
- How many students scored above 75?
- How many students failed (marks below 35)?
- Find the topper's marks.
- Find the average marks of students scoring above 70.
- Replace all marks below 60 with 60.
- 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()
π― 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:
shape,size,ndim,dtype)reshape()Starter Code
Tasks
1. Display the Marks
Print the complete marks array.
2. Check Array Properties
Print:
3. Indexing & Slicing
4. Reshape the Array
Convert the 1D array into a 2 Γ 5 matrix.
Example:
5. Arithmetic Operations
Add 5 grace marks to every student.
Then multiply every mark by 2.
6. Aggregate Functions
Find:
7. Boolean Indexing
Display:
8. Matrix Operations
Using the reshaped (2 Γ 5) array:
9. Random Numbers
Generate marks for 5 new students between 50 and 100 using NumPy.
Example Output:
10. Bonus Challenge
Answer the following:
Expected Skills Covered
np.array()shapesizendimdtypereshape()sum()mean()max()min()std()transpose()np.random.randint()np.sort()