+ 2
Help me solve the code #0003
https://code.sololearn.com/ctrxdgNVw6Ro/?ref=app this gives output 28. but i don't understand how..?
2 Answers
+ 4
you should pay attention to the default value of the constructor def __init__ .. it takes two parameters of h = 10 & w = 10.. so if we instanitiate object a without passing arugements it should use the default values..
but in the example
a = geome(4)
we create an instance of the class passing 4 as arguement which changes the first parameter value & makes it 4 rather than the original default value ..
if you made the following changes :
a = geome(4 , 4)
it assigns both of h & w to value 4 so the result would be 8 + 8 = 16..
+ 4
In the code, on calling a.geome(4), self.h becomes 4, but self.w is assigned the default value of 10. Then, on calling a.rectangle(), you get the perimeter, which is 8+20 => 28.