Output: The area of the rectangle with the given sides 31, 19 = 589 2)Using Classes(User Input separated by spaces) Rectlength, ',', rectbreadth, '=', rectObj.areaofRect()) Print("The area of the rectangle with the given sides", RectObj = rectangle(rectlength, rectbreadth) # Call the method areaofRect() on the object with the length and breadth as the parameters taken from the user as static input. # Creating an object to represent the class. # Give the length and breadth as static input and store it in two variables. # Creating a method called areaofRect that returns the area with the given length and breadth of the rectangle # parameterized constructor is used to initialize its values (length and breadth of the rectangle).ĭef _init_(self, rectbreadth, rectlength): # parameterized constructor with breadth and length as arguments
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |