作业帮 > 综合 > 作业

求python3问题完成啊

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/07/25 14:43:23
求python3问题完成啊
class Rectangle:
""" A rectangle with a width and height. """
def __init__(self, w, h):
""" (Rectangle, number, number)
Create a new rectangle of width w and height h.
>>> r = Rectangle(1, 2)
>>> r.width
1
>>> r.height
2
"""
self.width = w
self.height = h
def area(self):
""" (Rectangle) -> number
Return the area of this rectangle.
>>> r = Rectangle(10, 20)
>>> r.area()
200
"""
求python3问题完成啊
太简单,我都差点不好意思回答了。def area(self):
        """ (Rectangle) -> number

        Return the area of this rectangle.
        >>> r = Rectangle(10, 20)
        >>> r.area()
        200
        """
        return self.width * self.height