Making a grade calculator using a simple Python Script.
Back to School/University season is here, and because school is going to be on a different medium/setting for a lot of us, let’s get together and build a grade calculator to calculate your current grade in any class! This is going to be done using a python script, which is essentially a Python code file (with functions) you can execute typically from a command line interface-Terminal! This is a great way to quickly double check your grade at any time of the semester!
Calculating grades can be an easier process by using a quick python script to consider the weights and percentages for you! So today, we will be designing and creating a python script which basically takes in the current grades from tests/assignments you have as inputs -> and calculates the total calculated and current grade in your class (at any particular moment!). Lets get started! Even though many online systems do this for us, it’s always good to double check! :)
Materials I Used
- A Code Editor — I use Vim, but you can use any editor that best suits you
- Python installed in your device (any version is fine!)
So our goal is to make a python script which takes in an array of grades as input, processes these inputs and computes the weighted average and sum, and then outputs the current grade in your class to the Terminal! How does this all work though? So essentially the script will accept these inputs as command line arguments. So when you type in the command to execute your script, like python script.py, you also add your grade inputs into the command as well! So essentially the command contains the grades in an array format for each category (quizzes, projects, assignments, homeworks, midterms, for example — depends on your class!).
The code for the Python script is linked here.
It’s really nice to have a double check sort of a tool with you to see where you are at in your class! Even if you haven’t completed or received grades yet, you could always input in your grades to assignments you have completed so far, compute the weights depending on your class, and get an output! This was so much fun, and making these little Python scripts are just the best way to get the hands-on experience with Python!