From ac78d7b08f90d3d89f304a78d5b92b1627d21390 Mon Sep 17 00:00:00 2001 From: Pranavwagh1 Date: Tue, 20 Jan 2026 19:29:49 +0530 Subject: [PATCH 1/2] Add student result processor utility --- other/student_result_processor.py | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 other/student_result_processor.py diff --git a/other/student_result_processor.py b/other/student_result_processor.py new file mode 100644 index 000000000000..b54ec726aae0 --- /dev/null +++ b/other/student_result_processor.py @@ -0,0 +1,65 @@ +""" +Student Result Processor + +This module provides utility functions to process student results, +including separating passed and failed students, identifying top +performers, and calculating pass percentage. +""" + + +def separate_students(students, pass_mark=75): + """ + Separate students into passed and failed lists. + + :param students: List of dictionaries with keys 'name' and 'marks' + :param pass_mark: Minimum marks required to pass + :return: Tuple (passed_students, failed_students) + """ + passed = [s for s in students if s["marks"] >= pass_mark] + failed = [s for s in students if s["marks"] < pass_mark] + return passed, failed + + +def top_performers(students, threshold=90): + """ + Get students scoring above a given threshold. + + :param students: List of student dictionaries + :param threshold: Minimum marks for top performers + :return: List of top-performing students + """ + return [s for s in students if s["marks"] >= threshold] + + +def pass_percentage(students, pass_mark=75): + """ + Calculate pass percentage. + + :param students: List of student dictionaries + :param pass_mark: Minimum marks required to pass + :return: Pass percentage as float + """ + if not students: + return 0.0 + + passed_count = sum(1 for s in students if s["marks"] >= pass_mark) + return (passed_count / len(students)) * 100 + + +if __name__ == "__main__": + sample_students = [ + {"name": "Pranav", "marks": 90}, + {"name": "Amit", "marks": 40}, + {"name": "Sneha", "marks": 95}, + {"name": "Rahul", "marks": 72}, + ] + + passed, failed = separate_students(sample_students) + top = top_performers(sample_students) + percentage = pass_percentage(sample_students) + + print("Passed:", passed) + print("Failed:", failed) + print("Top Performers:", top) + print("Pass Percentage:", percentage) + From 7fc3dfc111436eab2fd495717228d0c4acc6a1b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:06:00 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/student_result_processor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/other/student_result_processor.py b/other/student_result_processor.py index b54ec726aae0..5a7e03798097 100644 --- a/other/student_result_processor.py +++ b/other/student_result_processor.py @@ -62,4 +62,3 @@ def pass_percentage(students, pass_mark=75): print("Failed:", failed) print("Top Performers:", top) print("Pass Percentage:", percentage) -