Question: Class: Rectangle Write a class named Rectangle that represents a rectangle. The class should have the following data attributes and methods: Data Attributes: width: to
Class: Rectangle
Write a class named Rectangle that represents a rectangle. The class should have the following data attributes and methods:
Data Attributes:
width: to store the width of the rectangle.
height: to store the height of the rectangle.
Methods:
self width, height: Initializes the width and height of the rectangle.
areaself: Calculates and returns the area of the rectangle.
perimeterself: Calculates and returns the perimeter of the rectangle.
issquareself: Checks if the rectangle is a square ie if width equals height and returns True or False accordingly.
Write a program to create at least three Rectangle objects, input their width and height from the user, and then display their area, perimeter, and whether it is a square.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
