Project 4
Project 4
Analysis System
📝 Project Description:
This project:
Generates marks for 100 students in 5
subjects
Stores the data in a MySQL database
Calculates total and average marks using
Pandas
Visualizes top performers using Matplotlib
1. MySQL Table Setup
USE student_db;
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import mysql.connector
# 3. Save to MySQL
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="your_password", # Replace this
database="student_db"
)
cursor = conn.cursor()
finally:
if conn.is_connected():
cursor.close()
conn.close()
# 5. Plot
plt.figure(figsize=(12, 6))
plt.bar(top10['student_name'], top10['total'],
color='limegreen')
plt.xticks(rotation=45)
plt.title("Top 10 Students by Total Marks")
plt.xlabel("Student")
plt.ylabel("Total Marks")
plt.tight_layout()
plt.show()