早教吧作业答案频道 -->其他-->
求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
"""
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
"""
▼优质解答
答案和解析
太简单,我都差点不好意思回答了。
def area(self):
""" (Rectangle) -> number
Return the area of this rectangle.
>>> r = Rectangle(10, 20)
>>> r.area()
200
"""
return self.width * self.height
看了求python3问题完成啊cl...的网友还看了以下:
将N个矩形的宽W除以长L(W/L)得出N个(W/L),将N个(W/L)的值相加之后的和除以N,得出 2020-04-09 …
东西半球的分界线和南北半球分界线分别是()A.20°W和160°E,180°B.20°W和160° 2020-04-23 …
面对手中的地球仪,请你解答下面几个问题2~7.东西半球的分界线是()A.西半球20°W和160°E 2020-04-23 …
英语达.请把下列个题中的字母组成一个你所学过的单词.o,m,w,l,c,e,ee,g,h,t,io 2020-05-13 …
将括号内字母发音相同的单词归类W(e)st,tr(a)ffic,(c)lass,t(e)le)l, 2020-05-14 …
matlab 程序出错,帮我看看错在哪儿了函数function dvdt=huxi(t,v) gl 2020-05-16 …
如果令A、B、C、D……X、Y、Z这26个英文字母,分别等于百分之1、2、3、4、……HARDWO 2020-07-09 …
巴西的经度大约是40°W~80°W按照东西半球的划分东半球20°W~0°~160°E巴西的经度大约 2020-07-26 …
谁能帮我组个英语单词①e、n、o、p、t、w、y②e③d、t、y④b、c、f、m、p、r、t、v⑤ 2020-07-29 …
如果令A、B、C、D……X、Y、Z这26个英文字母,分别等于百分之1、2、3、4、……HARDWOR 2021-02-09 …