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): self.name = name self.level = level self.numberOfStudent = numberOfStudent def get_name(self): return self.name 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 {self.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)
2 Likes

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 essayservicescanner.com 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.

When working with code, I`d recommend you to check the HTML and CSS of the site through special validation services.

When working with code, I`d recommend you to check the HTML and CSS of the site through special validation services. They can scan the code and display errors, such as: not closed tag; not recommended characters in links; used not recommended tag; not specified required attribute; and others. Then you’ll know exactly what’s wrong and fix it faster. That’s what they teach us to do in asa college miami florida programming classes. Also note that the value of the id attribute in the HTML code should not be repeated. And don’t use more than three selectors, because it affects the site productivity.

hi there guys, thanks for useful topic