Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
9
4
58
6.3K
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr obj is an instance of the Square class. obj.side is assigned a value of 8. When the function is called, 8 is squared in the return statement. The print statement gives us both the value of obj.side and the value of the return - so, 8 64
English
0
0
6
344
Tanuj Raghav
Tanuj Raghav@RaghavTanuuuj·
@PythonPr 8, 64 ? Why object is a squared class & object.side is assigned as 8, we’ll get 64 as soon as function being called. Finally, give us the value
English
0
0
4
161
Burger King
Burger King@BurgerKing·
A better Whopper made for you, perfect down to the last bite. There’s a new king and it’s you!
English
0
333
4.3K
24.2M
Maya N
Maya N@mayasolos·
@PythonPr 8 64. Python lets you just slap side onto the instance after creation and everything still works. getArea() happily squares it. Somewhere a Java dev is sweating 😎
English
0
0
3
263
KbarisHatipoglu
KbarisHatipoglu@KbarisHatipoglu·
@PythonPr >>> class Rectangle: ... def getArea(self): ... return self.long*self.short ... >>> obj.long=8 >>> obj.short=4 >>> print(obj.long,obj.short,obj.getAreaRectangle()) 8 4 32
English
0
0
0
42
mirage🦋
mirage🦋@umeed_aab_nhi_h·
@PythonPr Oop i think I'm forgetting these concepts i need to brush up😭😭
English
0
0
0
10
Paylaş