Home / Expert Answers / Computer Science / given-the-class-account-complete-the-function-main1-account-that-takes-a-list-of-account-objects-a-pa622

(Solved): Given the class Account , complete the function main1_account that takes a list of Account objects a ...



Given the class Account , complete the function main1_account that takes a list of Account objects as a parameter, and prints out each account name and number, as shown below.

class Account:
Class representing a bank account.
def __init_(self, num, name, holder, balance):
self.num = num \# accoun

Given the class \( \quad \) complete the function \( \quad \) that takes a list of \( \quad \) objects as a parameter, and pr
class Account: "'Class representing a bank account'.' def __init_(self, num, name, holder, balance): self.num = num \# account number self.name = name \# account name e.g. 'saving', 'credit' etc. self.holder holder \# name of the account holder self.balance balance \# initial balance def __str__(self): desc = self.name account, number self.num) return desc def deposit(self, amount): self.balance amount def is_positive_balance(self): return self.balance Given the class complete the function that takes a list of objects as a parameter, and prints out each account name and number, as shown below. Example usage: >> acc = [Account (218911, 'saving', 'Cleo', 1210.70), Account(315917, 'saving', 'Jo', 10210.40), Account(419918, 'investment', 'Amy', 1500.80), Account(518910, 'credit', 'Jessica', 3000.35), Account(212912, 'saving', 'Patrick', 10100.00), Account(617915, 'investment', 'Damian', 1810.70), Account(418912, 'credit', 'Stanley', 4500.65), Account(515913, "credit', "Omar', 6000.25), Account(218919, 'saving', 'Nat', 1900.45), Account(810911, 'credit', 'Andrew', 3200.86)] >> main1_account(acc) output: saving's account, number 218911 saving's account, number 315917 investment's account, number 419918 credit's account, number 518910 saving's account, number 212912 investment's account, number 617915 credit's account, number 418912 credit's account, number 515913 saving's account, number 218919 credit's account, number 810911


We have an Answer from Expert

View Expert Answer

Expert Answer



Here's the implementation of the Account class and the main1_account function that takes a list of Account objects and prints out each account name and number:



Here, we define the Account class with a constructor that takes four parameters: num for the account number, name for the account name, holder for the name of the account holder, and balance for the initial balance. We also define a __str__ method that returns a string representation of the account in the format "account name's account, number account number". Finally, we define two methods, deposit and is_positive_balance, that update the account balance and check if the account balance is positive, respectively.


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe