Repository navigation
Expand file tree
/
Copy pathstudent_grading_system.py
More file actions
53 lines (47 loc) Β· 1.98 KB
/
Copy pathstudent_grading_system.py
File metadata and controls
53 lines (47 loc) Β· 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Student Grading System π
π€ Author: PJ (@pjprogrammers)
π License: MIT
π GitHub Profile: https://github.com/pjprogrammers
π GitHub Repo: https://github.com/pjprogrammers/python
Description: A simple interactive program that asks for student names and marks,
then assigns grades based on the marks using standard grading criteria.
"""
def main():
"""
Main function to run the grading system.
It asks how many students there are, takes each student's name and marks,
then prints their grade accordingly.
"""
# Ask the user for the total number of students
try:
n = int(input("Enter Number Of Students β "))
except ValueError:
print("β οΈ Invalid input. Please enter a valid integer for the number of students.")
return # Exit if input is invalid
# Loop through each student to get their name and marks
for i in range(1, n + 1):
# Ask for the student's name
student_name = input(f"Enter Name Of Student {i} β ").strip()
# Ask for the student's marks, expecting a floating point number
try:
marks = float(input(f"Enter Marks Of Student {i} β "))
except ValueError:
print("β οΈ Invalid marks. Please enter a valid number.")
continue # Skip to next student if marks input is invalid
# Determine and print the grade based on the marks
if 80 <= marks <= 100:
print(f"{student_name} - Grade A π")
elif 70 <= marks < 80:
print(f"{student_name} - Grade B π")
elif 50 <= marks < 70:
print(f"{student_name} - Grade C π")
elif 35 <= marks < 50:
print(f"{student_name} - Grade D")
elif 0 <= marks < 35:
print(f"{student_name} - Reappear π")
else:
# Marks outside 0-100 range are invalid
print(f"β οΈ Invalid marks for {student_name}. Please enter marks between 0 and 100.")
if __name__ == "__main__":
main()