导读:求帮忙做一个python3问题Write a class called Widget with an __init__ 求帮忙做一个python3问题Write a class called Widget with an __init__ method. Each Widget should have an instance variable called "name" a...
求帮忙做一个python3问题Write a class called Widget with an __init__
求帮忙做一个python3问题
Write a class called Widget with an __init__ method. Each Widget
should have an instance variable called "name" and an instance variable
called "cost" that represents a cost in dollars; those values are passed
in when a Widget is created. Also write a method in class Widget
called "is_cheap", which returns True if the cost is less than $10, and
False otherwise.
写一个class叫做widget,用__init__ method每一个widget应该有一个可替换的可变量叫做“name”还有一个可变量叫做“cost”,后面那个“cost“代表着消耗的钱,这些应该可以pass进去如果一个widget建成.还有一个method in class widget叫做”is_cheap",如果低于$10就是true,否则则是false
谢谢啦,急求帮助啊
ppgs
1年前他留下的回答
已收到1个回答
痞子兰
网友
该名网友总共回答了22个问题,此问答他的回答如下:采纳率:100%
class Widget(object):
def __init__(self, name, cost):
self.name = name
self.cost = cost
def is_cheap(self):
return self.cost < 10
1年前他留下的回答
10
以上就是小编为大家介绍的求帮忙做一个python3问题Write a class called Widget with an __init__ 的全部内容,如果大家还对相关的内容感兴趣,请持续关注上海建站网!
标签:
内容声明:网站所展示的内容均由第三方用户投稿提供,内容的真实性、准确性和合法性均由发布用户负责。上海建站网对此不承担任何相关连带责任。上海建站网遵循相关法律法规严格审核相关关内容,如您发现页面有任何违法或侵权信息,欢迎向网站举报并提供有效线索,我们将认真核查、及时处理。感谢您的参与和支持!