0

Can anyone explain this output?

class Rectangle: def __init__(self, width, height,color,digonal): self.width =6 self.height = 7 self.color="blue" self.digonal=digonal rect = Rectangle(7,"8","red","at 45 angle") print(rect.height,rect.color,rect.width,rect.digonal) #output # 7 blue 6 at 45 angle

14th Apr 2020, 8:10 AM
Ramya Thiurmalisamy
Ramya Thiurmalisamy - avatar
1 Resposta
+ 1
rect = Rectangle(7,"8","red","at 45 angle") By this creating an object of class Rectangle by passing values to constructor... But in implementation, except for diagonal value passed, Remaing three width=6 height=7,color="blue", not changing.. print(rect.height,rect.color,rect.width,rect.digonal) Here getting values by object as rect.height returns height value 7 rect.color returns color value "blue" rect.width return width=6 rect.digonal return diagonal value "at 45 angle" [this is one going to changed in object creation by code]...
14th Apr 2020, 8:19 AM
Jayakrishna 🇮🇳