-
-
Notifications
You must be signed in to change notification settings - Fork 50k
Add student result processor utility #14185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| """ | ||
| 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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: Please provide type hint for the parameter: Please provide type hint for the parameter: |
||
| """ | ||
| 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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As there is no test file in this pull request nor any test function or class in the file Please provide return type hint for the function: Please provide type hint for the parameter: Please provide type hint for the parameter: |
||
| """ | ||
| 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) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file
other/student_result_processor.py, please provide doctest for the functionseparate_studentsPlease provide return type hint for the function:
separate_students. If the function does not return a value, please provide the type hint as:def function() -> None:Please provide type hint for the parameter:
studentsPlease provide type hint for the parameter:
pass_mark