Compsci 06, Spring 2011, Files/Dictionaries, April 24
Name____________________ net-id _________
Name____________________ net-id _________
Name____________________ net-id _________
The data from sites that rate faculty members might look like what's
shown below: Each line shows a school, the name of a faculty
member, the department, a rating on a 0-5 scale, and the IP address
from which the rating was made (last names are shown for brevity,
the full-name would be recorded).
Duke:Astrachan:Computer Science:4:152.3.250.1
Duke:Forbes:Computer Science:4:152.3.250.1
Duke:Astrachan:Computer Science:5:153.39.0.22
Stanford:Parlante:Computer Science:3:152.3.250.1
Stanford:Sahami:Computer Science:4:152.3.150.1
Stanford:Lattin:Business:5:153.39.0.22
Duke:Fullenkamp:Economics:4:152.3.250.1
Duke:Leachman:Econonmics:3:152.3.250.1
Duke:Bonk:Chemistry:4:152.3.250.1
Write a function that takes a filename for a file in the format shown
and the name of a school (both strings) as parameters and which
returns a list of (name,department,rating)
three-tuples
that are rank-ordered by average-rating, highest-to-lowest, for all
professors in the school. If there are ties, break them by the
alphabetic/lexicographical ordering of professor name.
def rankings(filename,school):
"""
filename is name of file in format shown (string)
school is a string
return list of 3-tuples ordered by faculty rating, high-to-low
"""