Challenge 1: Implement a Rectangle Class

This lesson covers a basic exercise on classes and constructors.

Problem Statement

  1. Implement a class named Rectangle to store the coordinates of a rectangle given the top-left corner (x1, y1) and the bottom-right corner (x2, y2).

  2. Implement the class constructor with the parameters (x1, y1, x2, y2) and store them in the class instance using the self keyword.

Input

Given a class Rectangle

Output

Implement the class constructor and output if the rectangle can be created with the given the coordinates.

Sample Input

x1 = 2, y1 = 7, x2 = 8, y2 = 4

Sample Output

Rectangle(2, 7, 8, 4) created

Get hands-on with 1200+ tech skills courses.