================================================================================
  Question 24: Student CSV Records Analysis
================================================================================

FULL QUESTION:
Write a Python program that does the following:
1. Create a CSV file named students.csv with the following columns:
   Roll_No, Name, Marks
2. Insert at least 5 student records into the file.
3. Read the data from the CSV file and display:
   - The student with the highest marks.
   - The average marks of the class.

SHORT QUESTION:
Creates students.csv with student records, computes the highest scoring student, and calculates class average marks.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Question 24: Student CSV Records Analysis

- Prerequisites: Python 3.x (Standard library csv module).
- Setup: Creates 'students.csv' in the local directory automatically.
- How to Run: python question_24.py
- Expected Behavior: Creates students.csv, populates 5+ records, reads the file, identifies top student, and prints class average.

================================================================================
SOURCE CODE FILES:
================================================================================

1. question_24.py
--------------------------------------------------------------------------------
import csv

data = [
    [1, "Aaa", 50],
    [2, "Bbb", 60],
    [3, "Ccc", 55],
    [4, "Ddd", 70],
    [5, "Eee", 80],
]

with open("students.csv", "w", newline="", encoding="utf-8") as file:
    writer = csv.writer(file)
    writer.writerow(["Roll_No", "Name", "Marks"])
    writer.writerows(data)

with open("students.csv", "r", encoding="utf-8") as file:
    reader = csv.reader(file)
    next(reader)
    students = list(reader)

top_student = students[0]
total_marks = 0

for row in students:
    current_marks = int(row[2])
    total_marks += current_marks

    if current_marks > int(top_student[2]):
        top_student = row

average_marks = total_marks / len(students)

print(f"Top Student: {top_student[1]} with {top_student[2]} marks")
print(f"Class Average: {average_marks:.2f} marks")
--------------------------------------------------------------------------------
