FAQ: Survey of Computer Science - The Tale of Kenny - Kenny the Teacher

Hey guys,

I’m just starting out and am curious about a few lines I don’t understand. Can someone please explain the following:

top_of_class = list(grades.keys())[0] - This is a list of all grades based on their number?

And (grades[student_a] > grades[top_of_class]): - Top of class isn’t defined yet?

Is the Else if code necessary in this situation?

Hopefully you have covered dictionaries and some of their methods?

student_grades = {"Jeremy" : 87, "Kyla" : 82, "Ayesha" : 90, "Aleida" : 94, "Todd" : 79, "Maxwell" : 98, "Yolonda" : 81, "Kiyoko" : 71, "Dagmar" : 73, "Laura" : 91, "Shimeah" : 81, "Songqiao" : 92, "Frankie" : 87, "Natalia" : 95, "Gonzalo" : 82, "Pavel" : 78}

The keys in the dictionary above are the student names. The above statement extracts a list of the just the names, and sets the temporary variable to the first item in the list. We will be going through that list to pair up the highest and lowest grades while accessing the dict values by key.

It is defined in the line above, as a student name from the list.