Search⌘ K
AI Features

Challenge: Devise a Shape System

Explore how to design a class hierarchy in Python by creating a shape system that includes squares and rectangles. Learn to use instance, class, and static variables and methods to manage shape properties like endpoints, area, perimeter, and object counters effectively. This lesson prepares you to extend the system to new shapes while applying object-oriented programming concepts.

We'll cover the following...

Problem statement

This challenge is to test your basics for designing a class hierarchy. You have to create a shape system, that accepts two shapes for now: a Rectangle and a Square. Here are the technicalities:

  • Each shape’s object, when initialized, would be given the length of its sides. For example:
    • When initializing a Square object, pass a number to set the length of its sides.
...
svg viewer