Page 136 - Informatics_Practices_Fliipbook_Class12
P. 136
a. The median for the five subjects is _____ , ______, _______, ______, ______
b. The highest value for the five subjects is : _____ , ______, _______, ______, ______
c. The lowest value for the five subjects is : _____ , ______, _______, ______, ______
d. ______________ subject has two outliers with the value ________ and ________
e. ______________ subject shows minimum variation
Ans. a. medians = df.median()
print(f"The median for the five subjects is {medians['English']}, {medians['Maths']},
{medians['Hindi']}, {medians['Science']}, {medians['Social Studies']}")
Output:
The median for the five subjects is 80.0, 50.0, 55.0, 56.0, 76.0
b. highestValues = df.max()
print(f"The highest value for the five subjects is: {highestValues['English']},
{highestValues['Maths']}, {highestValues['Hindi']}, {highestValues['Science']},
{highestValues['Social Studies']}")
Output:
The highest value for the five subjects is: 95, 95, 90, 94, 95
c. lowestValues = df.min()
print(f"The lowest value for the five subjects is: {lowestValues['English']},
{lowestValues['Maths']}, {lowestValues['Hindi']}, {lowestValues['Science']},
{lowestValues['Social Studies']}")
Output:
The lowest value for the five subjects is: 60, 33, 39, 48, 54
d. subjectWithOutliers = 'Social Studies'
q1 = df[subjectWithOutliers].quantile(0.25)
q3 = df[subjectWithOutliers].quantile(0.75)
iqr = q3 - q1
lowerBound = q1 - 1.5 * iqr
upperBound = q3 + 1.5 * iqr
outliersValues = df[(df[subjectWithOutliers] < lowerBound) |
(df[subjectWithOutliers] > upperBound)][subjectWithOutliers]
print(f"{subjectWithOutliers} subject has two outliers with the values
{outliersValues.iloc[0]} and {outliersValues.iloc[1]}")
Output:
Social Studies subject has two outliers with the values 95 and 54
e. subjectMinVariation = df.std().idxmin()
print(f"{subjectMinVariation} subject shows minimum variation")
Social Studies subject shows minimum variation
122 Touchpad Informatics Practices-XII

