Skip to content

codeKrantz/Final-Grade-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Final Grade Calculator

A small project that computes the score you need on a final exam to reach a target overall grade.

What this project contains

  • final_grade_calculator.py — the main Python program.
    • It can run as a command-line calculator.
    • It can also start a Flask web server that serves the HTML interface and calculates results via a JSON API.
  • index.html — the web UI for the calculator.
    • It contains the form, validation, and result display.
    • It sends the input values to the Python backend at /calculate.

How the calculation works

The calculator uses this formula:

desired = current * (1 - w) + final_score * w

Where:

  • current is your current grade percentage.
  • w is the final exam weight as a decimal (final weight % / 100).
  • desired is the overall grade percentage you want.

Solving for final_score gives:

final_score = (desired - current * (1 - w)) / w

If the result is negative, that means your current grade is already high enough to reach the desired grade even if you score 0 on the final.

How to use it

Run the command-line version

python final_grade_calculator.py

Then enter:

  1. Current grade (%)
  2. Final exam weight (%)
  3. Desired final grade (%)

The script will print the percent you need on the final.

Run the web version

python final_grade_calculator.py --web

Then open your browser at:

http://127.0.0.1:5000

The web page will show a form with three inputs and a calculate button.

How the HTML page is connected

The web UI in index.html does not compute the final score entirely in the browser. Instead, it sends the values to the backend with a POST request to /calculate. The backend validates the inputs, performs the same grade calculation, and returns the needed score.

Input validation rules

  • Current grade: 0 to 200
  • Final exam weight: 1 to 100
  • Desired grade: 0 to 200

If the browser cannot reach the server, the page shows an error message telling you the Python server may not be running.

Notes

  • The Python backend and the web UI share the same calculation logic via the /calculate endpoint.
  • The HTML page is not a standalone static calculator in this repository because it depends on the Flask backend to return results.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors