#---------------------------------------------------------------------- # Program to print out student performance. # Final Version with Lists # # Copyright (C) February 5, 2018 -- Dr. William T. Verts # # In this version we have one list for student entries instead of # two, but each entry is a list itself consisting of a name and a # score. Note that Roster[0][0] is "Fred" and Roster[0][1] is 76, # Roster[1][0] is "Sam" and Roster[1][1] is 23, etc. Now to add a # new student we need only add a new [name,value] list to the end # of Roster. #---------------------------------------------------------------------- def Student (Name,Grade): S = "" while (len(S) < Grade): S = S + "|" # BarGraph S = S + " " + Name + " " + str(Grade) # Name and Grade if (Grade >= 90): S = S + " A" # Letter Grade elif (Grade >= 80): S = S + " B" elif (Grade >= 70): S = S + " C" elif (Grade >= 60): S = S + " D" else: S = S + " F" return S Roster = [["Fred",76], ["Sam",23], ["Mary",92]] Counter = 0 while (Counter < len(Roster)): print Student(Roster[Counter][0],Roster[Counter][1]) Counter = Counter + 1