from random import randrange class Student: def __init__(self, id_, name): self.id_ = id_ self.name = name def enroll(self,section): section.enroll(self.id_) def drop(self, section): section.drop(self.id_) def print_name(self): print "%s, id:%s" %(self.name,self.id_) class Course: def __init__(self, name, section, instructor_name): self.name = name self.section = section self.i_name=instructor_name self.list = [0] self.list.remove(0) def enroll(self, student_id): self.list.append(student_id) print "Added one student" def drop(self, student_id): self.list.remove(student_id) def roster(self): print "the list of students in the %s (section %s) class:" %(self.name, self.section) #n=len(self.list) for i in self.list: print i def main(): s1 = Student(123,"Stuart Smith") s2 = Student(234,"Anna Clark") s3 = Student(132,"Mark Stone") s4 = Student(324,"Helen Jones") c2434=Course("MTH01",2434,"Natalia Novak") c3452=Course("MTH03",3452,"John Smith") s1.print_name() s2.print_name() s3.print_name() s4.print_name() s1.enroll(c2434) # using the variable's name to enroll, not the section # s2.enroll(c2434) # s3.enroll(c3452) # s4.enroll(c3452) # s1.enroll(c3452) # c2434.roster() c3452.roster() s1.drop(c2434) # using the variable's name to drop, not the section # s4.drop(c3452) c2434.roster() c3452.roster() main()