EX.
NO: 10
71762305009 NUMPY
26.03.2025
AIM:
To implement NumPy library in python to analyze the data.
PROGRAM:
1.A university wants to analyse the performance of students based on their
study hours and previous exam scores.
The university has collected student data as follows:
study hours ( in hours per week)
[5, 10, 15, 20, 25, 30, 35, 40]
previous exam scores( out of 100)
[50, 55, 60, 65, 70, 75, 80, 85]
current exam scores(out of 100)
[52, 60, 67, 70, 75, 78, 85, 90]
1.Using NumPy, store the data in appropriate arrays.
2.Calculate the mean , median and standard deviation of the current exam
scores.
3. Find the correlation between study hours and exam scores using NumPy.
CODE:
import numpy as np
study_hours = np.array([5, 10, 15, 20, 25, 30, 35, 40])
previous_exam_scores = np.array([50, 55, 60, 65, 70, 75, 80, 85])
current_exam_scores = np.array([52, 60, 67, 70, 75, 78, 85, 90])
mean_current_exam_scores = np.mean(current_exam_scores)
median_current_exam_scores = np.median(current_exam_scores)
stddev_current_exam_scores = np.std(current_exam_scores)
correlation = np.corrcoef(study_hours, current_exam_scores)[0,1];
print("Study hours:",study_hours);
print("Previous exam scores:",previous_exam_scores);
print("Current exam scores:",current_exam_scores);
print("Mean of current exam scores:", mean_current_exam_scores)
print("Median of current exam scores:", median_current_exam_scores)
print("Standard Deviation of current exam scores:",
stddev_current_exam_scores)
print("Correlation between study hours and current exam scores:", correlation)
OUTPUT:
RESULT:
The python program using NumPy has been implemented and verified
successfully.