If I have a list and I already have split the line in the file. I also have figured out the code to average the numbers in the list now I have want to figure out a way to somehow take the average from the list of numbers and give it a letter grade.Can anyone help?

def main():
in = open ("jjinput.txt", "r")
out = open ('ll.output', 'w')
lin = fin.readline()
x = lin.split()
h=(int (x [1])/3
j=(int (x [2])/6
k=(int (x [3])/4
l=(int (x [4])/5
average = h+j+k+l

print average
write = str (x[0])+ " " +(str (average))
out.write (write)

This is what I have basically it takes a list of numbers from a file and puts the name of a person and the average grade number next to it, i would like the letter grade to go next to it somehow.like

John 88 B right now it just comes up like John 88 in my output.

Below 60 gets F, 60 to 69 D, 70 to 79 C, 80 to 89 B, 90 above an A.
Im thinking I would use an else statement but I dont really understand how to use it.

Edited 6 Years Ago by sss33: n/a

Double check your average calculations, as generally you can not add averages together. See "Conditionals" here.

if average > 90:
    grade = "A"
Etc

j

Edited 6 Years Ago by sss33: n/a

This article has been dead for over six months. Start a new discussion instead.