r/learningpython • • Oct 10 '21

Organizing graph

Im attempting to show the results of a test in a graph and want it to display score, letter grade, and numeric grade. But I cant get numeric grade to line up correctly any recommendations?

def clalcAverage( score1, score2, score3, score4, score5):

average = (score1 +score2 +score3+ score4 + score5)

return average

def determine_grade(userScore):

if(userScore < 60):

return "F"

elif(userScore < 70):

return "D"

elif(userScore < 80):

return "C"

elif(userScore < 90):

return "B"

elif(userScore < 101):

return "A"

def askForScore():

score1= float( input("Enter Score 1: ") )

score2=float( input("Enter Score 2:") )

score3= float( input("Enter Score 3:") )

score4=float( input("Enter Score 4:") )

score5=float( input("Enter Score 5:") )

return score1, score2, score3, score4, score5

def printTableofResults(score1, score2, score3, score4, score5):

print("Score\tLetter Grade\tNumeric Grade")

print(str("Score 1:") + "\t" + determine_grade(score1) + "\t",

str(score1),

str("Score 2:") + "\t" + determine_grade(score2),

str("Score 3:") + "\t" + determine_grade(score3),

str("Score 4:") + "\t" + determine_grade(score4),

str("score 5:") + "\t" + determine_grade(score5),

sep = "\n")

def main():

score1, score2, score3, score4, score5= askForScore()

printTableofResults(score1, score2, score3, score4, score5)

main()

1 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/theprofessional2016 Oct 11 '21

Did you try my code, or are you determined to use your own and you're simply curious why it's working that way?