Grade Average Calculator

python3

#1

I am new to python and am just trying to make my first program to compute what someone needs to get on their final to obtain their target grade (similar to gpahub https://gpahub.net/final-grade-calculator). I have a formula that works but cannot seem to call the arguments within the function without running into an error. As I said, I just started learning python so I am sure this is just a simple mistake. Any help would be greatly appreciated.
Here is my code thus far in Python 3:

total = 0
q = 1
score = input("Enter a score:")
while score != "stop":
    q += 1
    total = total + int(score)
avg = total / q
print(avg)

#2

this needs to be placed the loop:

score = input("Enter a score:")

given you want multiply scores.

in many languages, we have do/while loops, which would be ideal. Not in python

just declare score before the loop and give it any value you like, doesn't matter, give you will overwrite it with prompting the user for input (inside the loop)


#3

Also plan the order of the statements in the loop carefully, so that when the user enters "stop", you don't attempt to add that to total.

You may want to read about break and continue Statements, and else Clauses on Loops.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.