Write a program that allows a secretary to store the names, total student population and
programmes available of all universities in Zimbabwe and sorts them in ascending order
according to student pop. The program should allow a searching facility by name and
updating of population. Make use of functions and data structures
class University():
def __init__(self, names, population,programmes ):
self.names = names
self.population = population
self.programmes = programmes
def display(self):
print("Students: ", self.names)
print("Population: ", self.population)
print("Programmes: ", self.programmes)
print()
universities=[]
universities.append(University("Tim,Peter,Mary...",1500,"Math,IT"))
universities.append(University("Mike,Julia...",1200,"Biologi,IT"))
universities.append(University("Den,Ann...",1800,"Physics,IT"))
universities.sort(key=lambda x: x.population)
for u in universities:
u.display()
Comments
Leave a comment