我正在学习如何使用课堂,到目前为止我已经取得了以下成就:
class customer:
def __init__ (self, name, ID, money):
self.name = name
self.ID = ID
self.money = money
def deposit(self, amount):
self.money = self.money+amount
def withdraw(self, amount):
self.money = self.money-amount
mike = customer('Mike', 1343, 1884883)
john = customer('John', 1343, 884839)
steve = customer('Steve', 1343, 99493)
adam = customer('Adam', 1343, 10000)
我想创建一个功能,根据客户拥有的资金量对其进行排序,但不确定如何进行排序。你知道吗
简单的插入排序,接收customer数组并根据货币对其进行排序。你知道吗
此代码将在将customer数组作为输入的customer类之外。你知道吗
这个问题可以有许多正确答案。书面解释。你知道吗
可以按如下属性对在位对象列表进行排序:
如果设置
reverse=False
,则列表按升序排列,其中reverse=True
按从最高到最低的顺序排列。你知道吗所以在你的情况下:
For more information check this question too
相关问题 更多 >
编程相关推荐