Python Program - Rectangle Class

preview_player
Показать описание
Create a class named Rectangle with two data members named I and w for storing the length and width of a rectangle. Include:-
1) Constructor to initialize the data members (l and w)
2) Two methods; one to find the area and another to find perimeter of the rectangle
Рекомендации по теме
Комментарии
Автор

Design a class to represent a rectangle with length and breadth as instance attributes. Create two rectangle objects, r1 and r2. Initialize the attributes using the constructor and do the following operations.
r3 = r1 + r2, where r3 is an another Rectangle object
r3’s length = r1’s length + r2’s length
r3’s breadth = r1’s breadth + r2’s breadth
Obtain a user-friendly string representation of the Rectangle object as Length is 30 and Breadth is 11 by overriding __str__( ).
print(r3)
Compare the dimensions of r1 and r2.
r1 == r2
r1 < r2
r1 > r2
r1 >= r2
r1 <= r2

bharathnaik
Автор

AREA AND PERIMETRERS SRE NOT PRINTED NO ATTRIBUTES

madavplc
visit shbcf.ru