Post Ticker

6/recent/ticker-posts

How to create a Simple GPA Calculator With Python

  Assalamu-Alikum, everyone, how are you! Today I will describe how to create a Simple GPA CalculatorWith Python 



To create the calculator first you should open Pycharm hear create a project, the supposed name is GPA Counter. You can try my video tutorial,




After creating projects in main.py at first you should define a function and in the function pass two parameters like--

def gpa(full_number, got_number):

Then check if the got number is less or equal to the total marks. To do that start a condition first. Like-

    if got_number <= full_number:
#calculation_of_gpa
else:
return "Error"

In #calculation_of_gpa comment you will calculate the GPA of the student. First, you should calculate the percentage of student's marks. like--

        parsent = (got_number * 100) / full_number

Thane calculet GPA. Like-----

        if parsent >= 80:
gpa = "5.00"
lg = "A+"
elif 80 > parsent >= 70:
gpa = "4.00"
lg = "A"
elif 70 > parsent >= 60:
gpa = "3.50"
lg = "A-"
elif 60 > parsent >= 50:
gpa = "3.00"
lg = "B"
elif 50 > parsent >= 40:
gpa = "2.00"
lg = "C"
elif 40 > parsent >= 33:
gpa = "1.00"
lg = "D"
elif parsent < 33:
gpa = "0.00"
lg = "No..."
return_txt = "Hi student, Your Result is:\nGPA: " + gpa + "\nLetter Great: " + lg
return return_txt

Then get two (total marks, and got marks) input from the user.

full_marks = int(input("Full Marks: "))
got_marks = int(input("Got Marks: "))

At last print the Function (gpa). Like-----

print(gpa(full_marks, got_marks))

All right. Now you can try your code projects.....

Full code would be:

def gpa(full_number, got_number):
if got_number <= full_number:
parsent = (got_number * 100) / full_number
if parsent >= 80:
gpa = "5.00"
lg = "A+"
elif 80 > parsent >= 70:
gpa = "4.00"
lg = "A"
elif 70 > parsent >= 60:
gpa = "3.50"
lg = "A-"
elif 60 > parsent >= 50:
gpa = "3.00"
lg = "B"
elif 50 > parsent >= 40:
gpa = "2.00"
lg = "C"
elif 40 > parsent >= 33:
gpa = "1.00"
lg = "D"
elif parsent < 33:
gpa = "0.00"
lg = "No..."
return_txt = "Hi student, Your Result is:\nGPA: " + gpa + "\nLetter Great: " + lg
return return_txt
else:
return "Error"

full_marks = int(input("Full Marks: "))
got_marks = int(input("Got Marks: "))

print(gpa(full_marks, got_marks))

If you face any problems when doing the project, plec comment hear or inbox me on Facebook or Mail, and I will highly try to give you a solution to you. Thanks a lot.

Post a Comment

0 Comments