Advertisement
vallec

Untitled

Sep 18th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. class BankAccount:
  2. def __init__(self, account_number, name, balance):
  3. self.account_number = account_number
  4. self.name = name
  5. self.balance = balance
  6.  
  7. def deposit(self, d):
  8. self.balance = self.balance + d
  9.  
  10. def withdrawing_money(self, w):
  11. self.balance = self.balance - w
  12.  
  13. def print_info(self):
  14. print(self)
  15.  
  16.  
  17. def __str__(self):
  18. return f'{self.account_number} {self.name} {self.balance}'
  19.  
  20. def __repr__(self):
  21. return f'{self.account_number} {self.name} {self.balance}'
  22.  
  23. acc1 = BankAccount("111", "Test1", 1.50)
  24. acc2 = BankAccount("222", "Test2", 2.50)
  25. acc3 = BankAccount("333", "Test3", 3.50)
  26. acc4 = BankAccount("444", "Test4", 4.50)
  27. acc5 = BankAccount("555 "Test5", 5.50)
  28. acc6 = BankAccount("666", "Test6", 6.50)
  29. acc7 = BankAccount("777", "Test7", 7.50)
  30. acc8 = BankAccount("888", "Test8", 8.50)
  31. acc9 = BankAccount("999", "Test9", 9.50)
  32. acc10 = BankAccount("000", "Test10", 10.50)
  33.  
  34. account_list = [acc1, acc2, acc3, acc4, acc5, acc6, acc7, acc8, acc9, acc10]
  35.  
  36. def max_balance(books):
  37. index = 0
  38. maxIndex = 0
  39. balance = -999999
  40. for account in account_list:
  41. if(account.balance > balance):
  42. balance = account.balance
  43. maxIndex = index
  44. index += 1
  45.  
  46. print(account_list[maxIndex])
  47.  
  48. def sort_by_name():
  49. print(sorted(account_list, key= lambda x: x.name))
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement