...

/

Solution Review: Devise a Shape

Solution Review: Devise a Shape

The solution to the 'Devise a Shape' challenge.

We'll cover the following...

Explanation

Before jumping straight to the code, let’s proceed bit by bit.

To initialize a shape, whether a Square object or a Rectangle object, we need a constructor for initialization (__init__()) in both classes. Here’s the snippet:

For the Square class:

def __init__(self, l):
  self.length = l

Here, length is the instance variable. ... ...

For the Rectangle class:

def __init__(self, l, w):
  self.length = l
  self.width = w

Here, length and width are ...

Access this course and 1400+ top-rated courses and projects.