This module focuses on object-oriented programming in Python, covering attributes, methods, operator overloading, and class-level versus instance-level attributes.
- Solution
- Description:
Task "Developer - Not Just a Coder":
- Implement a
Houseclass with attributes for the name and number of floors. The class should include a methodgo_tothat prints the floor numbers from 1 to the specified floor or an error message if the floor doesn't exist.
- Implement a
- Solution
- Description:
Task "Magical Buildings":
- Extend the
Houseclass to include special methods like__len__, which returns the number of floors, and__str__, which provides a formatted string representation of the house.
- Extend the
- Solution
- Description:
Task "Operator Overloading":
- Implement comparison operators (
__eq__,__lt__,__le__, etc.) for theHouseclass to compare buildings by their number of floors. Also, implement the__add__,__radd__, and__iadd__methods to increase the number of floors.
- Implement comparison operators (
- Solution
- Description:
Task "Construction History":
- Add a class-level attribute
houses_historyto track all created house objects. Implement the__new__and__del__methods to automatically record new houses and log when a house is demolished.
- Add a class-level attribute
- Solution
- Description:
Task "UrTube Platform":
- Implement a set of classes (
User,Video,UrTube) to simulate the behavior of a video-sharing platform, including user registration, video uploading, and video watching with age restrictions and playback tracking.
- Implement a set of classes (