Introduction
Colleges often require 75% attendance. This tracker reads a simple register, handles holidays, late marks and medical leave, and tells each student exactly where they stand — including how many classes they must attend to recover.
Problem statement
Objectives
- Parse a custom text format robustly
- Compute statistics with properties
- Find streaks with a single pass
- Solve a 'how many more' question with a loop
Features
- P, A, L and M marks plus holidays
- Validation with skipped-line reasons
- Percentages, warnings and shortages
- Longest absence streak
- Daily attendance chart
Concepts demonstrated
- Parsing
- Properties
- Streak detection
- Simple simulation
System architecture
Student stores its marks and computes counted, attended and percentage as properties; medical leave is excluded from the count. longest_absence scans marks keeping the current and best run. classes_needed adds hypothetical attended classes until the percentage reaches 75. parse builds students and daily rates while collecting problems instead of stopping.
Folder structure
Complete source code
main.py
What each file does
- main.py
- The Student class, the register parser and the report.
How to run it
Run
Test against the expected output
Expected output
Generated by running the project with tests/sample-input.txt. Your output should match tests/expected-output.txt exactly.
students: 101 Asha, 102 Ravi, 103 Meera, 104 Kiran 2026-11-02 P A P P 2026-11-03 P A L P 2026-11-04 P A P A 2026-11-05 holiday 2026-11-06 P P M P 2026-11-09 P A P P 2026-11-10 A P P P 2026-11-11 P A P A 2026-11-12 P P P X 2026-11-12 P P P P 11-13-2026 P P P P 2026-11-13 P P P 2026-11-16 P A P P 2026-11-17 P P P A
Testing
- Run
python main.py < tests/sample-input.txtand compare withtests/expected-output.txt. - Four lines are skipped: an invalid mark X, a repeated date, a date in the wrong format and a line with three marks.
- Ravi attended 3 of 9 classes (33.3%) and must attend the next 15 to reach 75%.
- Meera's medical leave doesn't count against her, so she is at 100%.
Common errors
Medical leave lowers the percentage
Exclude M marks from the number of classes counted.
A repeated date is counted twice
Keep a set of seen dates and skip repeats, as parse() does.
Possible improvements
- Read registers from CSV exported by a spreadsheet
- Report attendance per week
- Produce a printable list of shortage students
Additional challenges
- 1Show each student's attendance trend (improving or declining).
- 2Allow per-subject registers and combine them.
- 3Predict the final percentage if the current pattern continues.
Built and tested it yourself? Mark it to update your dashboard.