def get_area(self)
return self.width*self.height
となるのでしょう。
python3
1コード 2```class Rectangle: 3 def __init__(self,width,height): 4 self.width=width 5 self.height=height 6 def get_area(self,rec0,rec1): 7 return width*height 8 9rec0=Rectangle(5,8) 10rec1=Rectangle(4,6) 11print('rec0の面積',rec0.get_area()) 12print('rec1の面積',rec1.get_area()) 13Traceback (most recent call last): 14 File "<pyshell#40>", line 1, in <module> 15 print('rec0の面積',rec0.get_area()) 16TypeError: Rectangle.get_area() missing 2 required positional arguments: 'rec0' and 'rec1' 17この様にエラーを出してしまいます。 18return width*heightになにかしら不備があるのだと思うのですが分かりません... 19
あなたの回答
tips
プレビュー