#---------------------------------------------------------------------- # Program to print out student performance. # First Version using Lists # # Copyright (C) February 5, 2018 -- Dr. William T. Verts # # Here we have two explicit lists, one for Names and one for Scores, # and we use a counter to step through the lists one entry at a time. # The only requirement not currently checked is that Names and Scores # must have the same number of entries. To add more students, add # new entries both to Names and to Scores. #---------------------------------------------------------------------- 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 Names = ["Fred", "Sam", "Mary"] Scores = [76, 23, 92] Counter = 0 while (Counter < len(Names)): print Student(Names[Counter],Scores[Counter]) Counter = Counter + 1