Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BankAccount:
- def __init__(self, account_number, name, balance):
- self.account_number = account_number
- self.name = name
- self.balance = balance
- def deposit(self, d):
- self.balance = self.balance + d
- def withdrawing_money(self, w):
- self.balance = self.balance - w
- def print_info(self):
- print(self)
- def __str__(self):
- return f'{self.account_number} {self.name} {self.balance}'
- def __repr__(self):
- return f'{self.account_number} {self.name} {self.balance}'
- acc1 = BankAccount("111", "Test1", 1.50)
- acc2 = BankAccount("222", "Test2", 2.50)
- acc3 = BankAccount("333", "Test3", 3.50)
- acc4 = BankAccount("444", "Test4", 4.50)
- acc5 = BankAccount("555 "Test5", 5.50)
- acc6 = BankAccount("666", "Test6", 6.50)
- acc7 = BankAccount("777", "Test7", 7.50)
- acc8 = BankAccount("888", "Test8", 8.50)
- acc9 = BankAccount("999", "Test9", 9.50)
- acc10 = BankAccount("000", "Test10", 10.50)
- account_list = [acc1, acc2, acc3, acc4, acc5, acc6, acc7, acc8, acc9, acc10]
- def max_balance(books):
- index = 0
- maxIndex = 0
- balance = -999999
- for account in account_list:
- if(account.balance > balance):
- balance = account.balance
- maxIndex = index
- index += 1
- print(account_list[maxIndex])
- def sort_by_name():
- print(sorted(account_list, key= lambda x: x.name))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement