Building a Grading System in Python: A Step-by-Step Guide

Samuel Urah Yahaya
3 min readSep 1, 2023

--

Introduction

Grading systems are used to evaluate the academic performance of students. In this tutorial, we will create a simple grading system using Python. This program will ask the user to input the number of subjects they want to be graded on, the subject names, and the scores they obtained in their CATs and final exam. The program will then calculate the total score and assign a grade based on a predefined grading system. Finally, the program will print the grade for each subject along with the name of the user.

Creating the Program

To create the grading system program in Python, we need to follow the following steps:

Step 1: Print the Program Introduction To inform the user about the purpose of the program, we will print a simple introduction to the program. This can be done using the print statement in Python.

print('Hello, this is a grading system by SamY in co-operation with Mr Lasisi and some PFA students')
print("It uses the 100% scoring system")

Step 2: Collect User Details To begin grading the user, we will first ask the user to input their name and the number of subjects they want to be graded on. This can be achieved using the input function in Python.

name = input("Enter your name: ") 
numsub = int(input("Enter number of subjects: "))

Step 3: Define Functions To simplify the program, we will define two functions. The first function details() will ask the user to input the details of each subject, including the subject name. The second function val() will ask the user to input the scores they obtained in the two CATs and the final exam.

Step 4: Create a Loop to Iterate through the Subjects To enable the program to loop through the subjects, we will use a for loop in Python. The loop will iterate through the number of subjects the user inputs and call the details() and val() functions for each subject.

Step 5: Calculate the Total Score and Assign Grades After collecting the scores for each subject, we can now calculate the total score and assign a grade to the user based on the predefined grading system. We can achieve this by adding the scores obtained in each subject and comparing them to the grading system.

subscore = ca1+ca2+exam while subscore > 100: 
print("This score is invalid")
if subscore == 100:
print(name + ", Congratulations! This is an outstanding performance. " + "Your total is", subscore)
elif subscore >= 80:
print(name + ", You got an A. " + "Your total is", subscore)
elif subscore >= 70:
print(name + ", You got a B. " + "Your total is", subscore)
elif subscore >= 60:
print(name + ", You got a C. " + "Your total is", subscore)
elif subscore >= 50:
print(name + ", You got a D. " + "Your total is", subscore)
elif subscore >= 40:
print(name + ", You got a P. " + "Your total is", subscore)
else:
print(name + ", You have failed. " + "Your total is", subscore)
numsub = int(input("Enter number of subjects: "))
data = [] 
for x in range(numsub):
details()
score = val()
data.append([subname, score])
print("-------------------------------------------")
print("Thanks for trying it out. ")
print("Done by Samuel Yahaya, Mr Lasisi, and some students in PFA Geek Club")

Conclusion

Congratulations! You have now created a grading system in Python that can take input from the user, save the data to an array, and display the data to the user. With this basic framework, you can modify the code to suit your needs and create more complex grading systems or data entry systems.

Just in case you missed some parts of the code or got lost at some point, You can go to my Github account at SammY949 or click here, where the code is hosted and download it. Don’t forget to give it a star.

Thank you for reading this article and thank you for following along to build this project.

Originally published at https://samywrites.hashnode.dev.

--

--

Samuel Urah Yahaya
Samuel Urah Yahaya

Written by Samuel Urah Yahaya

I'm a versatile writer who explores technology, science, and more. Join me on a journey through the latest discoveries and unexpected insights.

No responses yet