0
Can anyone help me to Do this? i tried it but it is showing error in line 10.
class Rectangle: def __init__(self, width, height): self.w = width self.h = height def vol(self): # return volume return width*height w = Rectangle (int(input()) h = Rectangle (int(input()) obj = Rectangle(w, h) #call the function print (Rectangle .vol)
2 odpowiedzi
+ 4
https://code.sololearn.com/cV90Ks0f575T/?ref=app
The errors for taking input of width and height, you have use Rectangle class ,but it should be like this
w = int(input())
And for instead of Rectangle.vol() ,you have to call by object , means obj.vol() don't forgert it's also takes self as arguments so use obj and in return use self.width * self.height , self represents current object.
+ 1
Thanks I understood