Open process_accounts.py and put your name in the header. In process_accounts.py , define a class BankAccount that has the following: a variable that stores theaccount numberas aninteger, e.g.,...



  1. Openprocess_accounts.pyand put your name in the header.

  2. Inprocess_accounts.py, define a classBankAccountthat has the following:


    • a variable that stores theaccount numberas aninteger, e.g., 7451238

    • a variable that stores the owner'sfirst nameas a string

    • a variable that stores the owner'slast nameas a string

    • a variable that stores the decimal value of theaccount balanceas afloat

    • define the class constructor__init__that initializes all of these variables using formal parameters.

    • override the__str__and__repr__methods.


      • __str__mustexactlyreturn a string containing the account number, last_name, first_name, balance, e.g.,123456, Stone, Sam, 103956.32


      • __repr__mustexactlyreturn a string thatlooks likea constructor call for creating the object, e.g.,BankAccount(123456, Stone, Sam, 103956.32)



    • define acalculate_interestmethod that takesonlytwo parameters,self(as always) andrate. The method mustreturnthe amount of interest earned, which is calculated as (rate * account_balance).



  3. Create a list ofBankAccountobjects by reading the data fromaccounts.csvand creating a new BankAccount object from each line in the file.Your goal is to create a list of BankAccount objects -- no other list is needed!

    • CSVfiles are text files that have asimple format for exchanging structured data(Links to an external site.). You can view the CSV file in a text editor.

    • You can read the CSV file in Python the same way you do a plain text file.

    • The first line of the CSV file contains the column headers -- descriptive names for each comma-separated values. You must skip this line before when reading the accounts. How can you skip a line when reading a file? I leave it to your Google skills.

    • Each line of theaccounts.csvfile contains one account.

    • The format for each line is ,,,

    • You will need to make use of Python string's .split() and .strip() functions.



  4. Compute the following using the list ofBankAccountobjects you created and not any other list -- the goal is to work with custom classes. Working with other lists (like, lists of accounts balances) will lose substantial points:

    1. Print the total number of accounts.

    2. Compute and print theaverage balanceof all the accountspriortothe interest being added.


    3. Updateeach account's balance by adding an interest rate of 1.5% (0.015) to the account balance. You must use thecalculate_interestmethod in some way.

    4. Print the account with thelargest balanceafterinterest has been added.You must be printing the BankAccount object itself, which will leverage your __str__ implementation.

    5. Printtheaverage of all the accounts after this update.

    6. When you print decimals, truncate them to two decimal places usingone of the methods on this page(Links to an external site.), either 7.1.1 or 7.1.2. You donotneed to truncate the balance in the largest account.

    7. You must iterate using a for-loop.



Inputs files and expected outputs to earn aCor better
Sep 08, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here