School Catalogue python course

Hi there,

I’ve completed OOP School Catalogue. and I would like to see if I managed to completed up to standards?

Am I missing out on @decorators , setters, getters, del ? or I have completed this little project alright?

Github Gist

class School: def __init__(self, name, level, numberOfStudent): = name self.level = level self.numberOfStudent = numberOfStudent def get_name(self): return def get_level(self): return self.level def get_numberOfStudents(self): return self.numberOfStudent def set_numberOfStudents(self, new_amount): self.numberOfStudents = new_amount def __repr__(self): return f"A {self.level} school name {} with {self.numberOfStudent} students." class PrimarySchool(School): def __init__(self, name, numberOfStudent, pickuppolicy): super().__init__(name, 'primary', numberOfStudent) self.pickuppolicy = pickuppolicy def get_policy(self): return self.pickuppolicy def __repr__(self): parentRepr = super().__repr__() return parentRepr + "The pickup polity is {pickupPolicy}".format(pickupPolicy = self.pickuppolicy) mySchool = School("Codecademy", "high", 100) print(mySchool) print(mySchool.get_name()) print(mySchool.get_level()) mySchool.set_numberOfStudents(200) print(mySchool.get_numberOfStudents()) print('\n') testSchool = PrimarySchool("Codecademy", 300, "Pickup Allowed") print(testSchool.get_policy()) print(testSchool) print('\n') class HighSchool(School): def __init__(self, name, numberOfStudent, sportsTeams): super().__init__(name, 'High', numberOfStudent) self.sportsTeams = sportsTeams def getSportsTeams(self): return self.sportsTeams def __repr__(self): parent = super().__repr__() return parent + f" information of our sport Team {self.sportsTeams}" c = HighSchool("Codecademy High", 500, ["Tennis", "Basketball"]) print(c)

Hi, @fiko_94

Your code looks great!

One small tip, though. In repr of your HighSchool class you are returning a string with a list of sports teams with the brackets, so the print message looks a little bit bulky. I would suggest to add .join method to uncover the brackets so to speak, like so:

 def __repr__(self):
    parent = super().__repr__()
    return parent + f" information of our sport Team {', '.join(self.sportsTeams)}"

A High school name Codecademy High with 500 students. information of our sport Team Tennis, Basketball

1 Like

Thank you for your suggestion; once, I wanted to join the elements of an iterable and make it a string, but I completely forgot about the join method. Moreover, you even gave an example of its application, so much appreciation for it since I am just a beginner. I sometimes try to use the PhdEssay review service to read more texts and essay examples about Phyton, and helps me indeed, but it is so hard to apply all the gotten knowledge. I would appreciate it if you could give me some more tips or tasks like homework to train my skills. Now, I am going to continue my programming studies.