Can anyone help me to Do this? i tried it but it is showing error in line 10. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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)

20th Feb 2021, 2:26 AM
Rahul Prasad
Rahul Prasad - avatar
2 Answers
+ 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.
20th Feb 2021, 2:35 AM
Abhiyantā
Abhiyantā - avatar
+ 1
Thanks I understood
20th Feb 2021, 2:47 AM
Rahul Prasad
Rahul Prasad - avatar