⚡0 XP🔥0

Project 1: Student Report Card System

Lesson 32 of 33 ⏱ 5 min read ✎ 2 exercises ❓ 4-question quiz ▶ Runs Python

Build a complete report card program step by step - using lists, dictionaries, functions, loops, formatting and CSV files.

What we'll build#

A report card system that a teacher or institute could actually use:

  1. Store students and their marks in several subjects.
  2. Calculate total, percentage, grade and pass/fail for each student.
  3. Print a neat report card for every student.
  4. Rank the class and find subject toppers.
  5. Save the results to a CSV file that opens in Excel.

Concepts used: dictionaries, lists, functions, loops, conditionals, f-string formatting, sorted() with key, and file handling.

Step 1: Design the data#

Each student is a dictionary; the class is a list of these dictionaries:

students = [
    {"roll": 1, "name": "Asha Verma",  "marks": {"Maths": 92, "Science": 88, "English": 79, "Computer": 95}},
    {"roll": 2, "name": "Ravi Kumar",  "marks": {"Maths": 65, "Science": 72, "English": 58, "Computer": 81}},
    ...
]
हिंदी में समझें

किसी भी project की शुरुआत data को सही ढंग से organise करने से होती है। यहाँ हर student एक dictionary है (roll, name, marks), और marks भी एक dictionary है (subject → marks)। पूरी class इन dictionaries की एक list है।

ऐसा structure रखने से आगे की हर चीज़ - total, percentage, ranking - आसान हो जाती है। Real projects (जैसे database या Excel) में भी data इसी तरह rows और columns में होता है।

Step 2: Small functions for calculations#

Each function does one job - easy to test and reuse:

▶ Try it YourselfPython
Ctrl + Enter to run

Step 3: Print one report card#

▶ Try it YourselfPython
Ctrl + Enter to run

Step 4: The complete program#

Now combine everything: report cards for all students, ranking, class average, subject toppers and CSV export. Run it, then try adding a new student or subject.

▶ Try it YourselfPython
Ctrl + Enter to run
Tip

On your computer, open report_cards.csv in Excel or Google Sheets - you'll see a proper table.

Step 5: Ideas to extend the project#

Try these on your own computer - each one practises a different skill:

  1. Take input - ask the user how many students, then read names and marks with input(), validating marks with try/except.
  2. Load from CSV - read student data from a CSV file instead of writing it in code.
  3. Use classes - convert each student into a Student class with methods total(), percentage(), grade().
  4. Menu - add a while True menu: 1) Add student 2) Show report 3) Ranking 4) Save 5) Exit.
  5. Charts - install matplotlib and draw a bar chart of percentages.

Summary#

You built a real program by combining:

  • Data modelling with lists of dictionaries
  • Functions with one job each
  • Formatting with f-string alignment for tables
  • Sorting with key= for ranking
  • File handling with the csv module

Practice Exercises

Write your code, then press Check. Your program is tested automatically.

1

Grade and result functions

Complete the two functions used by the project:

  • get_grade(pct) → "A+" (90+), "A" (75-89.99), "B" (60-74.99), "C" (33-59.99), "F" (below 33)
  • result(marks) → "PASS" if every subject mark is ≥ 33, otherwise "FAIL" (marks is a dict of subject → mark)
2

Subject toppers

Write subject_toppers(students) that returns a dict mapping each subject to the name of the student with the highest mark in it. Each student is {"name": ..., "marks": {subject: mark}}.

Quick Quiz

Q1.

Which data structure best represents one student with name and marks per subject?

Q2.

Why do we split the program into small functions like get_grade() and percentage()?

Q3.

How do we rank students by percentage, highest first?

Q4.

What does f"{name:<10}" do?