# -------------------------------
# Project: Student Performance Analyzer
# Subject: Informatics Practices (065)
# Class: XII CBSE
# -------------------------------
import matplotlib
matplotlib.use("TkAgg") # Ensures graphs open in a new window in IDLE
import pandas as pd
import matplotlib.pyplot as plt
# -------------------------------
# Data Preparation
# -------------------------------
marks_series = pd.Series(
[78, 55, 89, 92, 60, 74, 88, 95, 45, 67],
index=["S1","S2","S3","S4","S5","S6","S7","S8","S9","S10"]
)
data = {
"Name": ["Amit", "Bhavna", "Chetan", "Divya", "Ekta",
"Farhan", "Gita", "Harsh", "Isha", "Jay"],
"Maths": [78, 55, 89, 92, 60, 74, 88, 95, 45, 67],
"Physics": [82, 60, 75, 85, 70, 68, 90, 96, 50, 72],
"Chemistry": [80, 58, 84, 88, 65, 70, 86, 93, 55, 69]
}
df = pd.DataFrame(data)
# -------------------------------
# Menu-driven Program
# -------------------------------
while True:
print("\n===============================")
print(" STUDENT PERFORMANCE ANALYZER")
print("===============================")
print("1. Show Series (Maths Marks)")
print("2. Show DataFrame (All Subjects)")
print("3. Line Graph (First 5 Students)")
print("4. Bar Chart (Average Marks per Subject)")
print("5. Pie Chart (Harsh’s Marks Distribution)")
print("6. Histogram (Maths Marks Distribution)")
print("7. Exit")
choice = input("Enter your choice (1-7): ")
if choice == "1":
print("\n---- Student Marks Series ----")
print(marks_series)
print("\nAverage Marks:", marks_series.mean())
print("Highest Marks:", marks_series.max())
print("Lowest Marks :", marks_series.min())
elif choice == "2":
print("\n---- Student Performance DataFrame ----")
print(df)
elif choice == "3":
plt.figure(figsize=(14,8))
df.head(5).set_index("Name")
[["Maths","Physics","Chemistry"]].plot(kind="line", marker="o")
plt.title("Marks of First 5 Students (Line Graph)")
plt.ylabel("Marks")
plt.xlabel("Students")
plt.grid(True)
plt.show()
elif choice == "4":
plt.figure(figsize=(14,8))
subject_avg = df[["Maths","Physics","Chemistry"]].mean()
subject_avg.plot(kind="bar", color=["skyblue","lightgreen","salmon"])
plt.title("Average Marks in Each Subject")
plt.ylabel("Average Marks")
plt.show()
elif choice == "5":
plt.figure(figsize=(14,8))
harsh_data = df[df["Name"]=="Harsh"].iloc[0,1:]
harsh_data.plot(kind="pie", autopct="%1.1f%%", startangle=90)
plt.title("Harsh's Marks Distribution")
plt.ylabel("")
plt.show()
elif choice == "6":
plt.figure(figsize=(14,8))
plt.hist(df["Maths"], bins=5, color="purple", edgecolor="black")
plt.title("Distribution of Marks in Mathematics")
plt.xlabel("Marks Range")
plt.ylabel("Number of Students")
plt.show()
elif choice == "7":
print("Thank you for using Student Performance Analyzer!")
break
else:
print("Invalid choice. Please try again.")