Unformatted text preview: cutoff is an int.""" result = # start with an empty list for k,v in grades.items(): if v >= cutoff: # NOTE: Alternate way to append to list result = result+[k] # Put k in a list and concatenate to end return result def give_extra_credit(grades,netids,bonus): """Gives bonus points to everyone in sequence netids This is a PROCEDURE. It modifies the contents of grades. It only modifies elements of grades with a key that appears in the sequence netids. Precondition: grades has netids as keys, ints as values. netids is a sequence of strings whose elements are all keys in grades (though not all keys appear in netids). Bonus is an int.""" for student in netids: if student in grades: # tests if student is a key in grades grades[student] = grades[student]+bonus...
View Full Document
- Spring '07
- Musical notation, netIDs, equal cutoff