早教吧作业答案频道 -->其他-->
python3问题求完成classRectangle:"""Arectanglewithawidthandheight."""definit(self,w,h):"""(Rectangle,number,number)Createanewrectangleofwidthwandheighth.>>>r=Rectangle(1,2)>>
题目详情
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
"""
return self.width * self.height
class RectangleCollection:
def __init__(self):
""" (RectangleCollection) -> NoneType
>>> rc = RectangleCollection()
>>> rc.rectangles
[]
"""
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
"""
return self.width * self.height
class RectangleCollection:
def __init__(self):
""" (RectangleCollection) -> NoneType
>>> rc = RectangleCollection()
>>> rc.rectangles
[]
"""
▼优质解答
答案和解析
class RectangleCollection:
def __init__(self):
""" (RectangleCollection) -> NoneType
>>> rc = RectangleCollection()
>>> rc.rectangles
[]
"""
self.rectangles = []
看了python3问题求完成cla...的网友还看了以下:
1.已有定义inta[10],*p;则正确的赋值语句是().A.p=100;B.p=a[5];C.p 2020-03-31 …
设a=(√5-1)/2,求(a^5+a^4-2a^3-a^2-a+2)/a^3-a∵2a=√5-1 2020-04-05 …
如图,点P(14,1),A(a,o),B(o,a)(a>o)确定三角形PAB的面积为18,求a的值 2020-04-06 …
计算题(P/A,10%,4)=3.1699(P/F,10%,1)=0.9091(P/A,10%,5 2020-04-07 …
如图,点P是O上任意一点,O的弦AB所在的直线与P相切于点C,PF为O的直径,设O与P的半径分别为 2020-05-13 …
如图所示,木板P下端通过光滑铰链固定于水平地面上的O点,物体A、B叠放在木板上且处于静止状态,此时 2020-06-12 …
(2014•崇明县二模)已知⊙O的半径为3,⊙P与⊙O相切于点A,经过点A的直线与⊙O、⊙P分别交 2020-06-23 …
一、已知数集M满足条件:若a∈M,则(1+a)/(1-a)∈M(a≠0,a≠±1)(1)若3∈M, 2020-07-30 …
椭圆.园O的半径为定长r,A是圆O内一个定点,P是圆上任意一点,线段AP的垂直平分线l和半径OP相 2020-07-30 …
(2002•泸州)如图,P为⊙O外一点,过点P作⊙O的两条割线,分别交⊙O于A、B和C、D,且AB 2020-07-31 …