Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need help coding this question. It's supposed to be done in python. Note: If a main function is used, ensure it is inside if

I need help coding this question. It's supposed to be done in python.

Note: If a main function is used, ensure it is inside if __name__ == __main__:

image text in transcribed

image text in transcribed

ErrorHandling.py Create a class called BankAccount with the following attributes: Variables balance int> transaction_history Methods get balance set balance (balance) get transaction_history set _transaction_history get_avg_transaction deposit (amount) withdraw (amount) The_initmethod should take an initial balance and default to O if nothing is entered transactionhistory should be initialized as a blank list Using whichever method you prefer (property/decorator) setup the get_balance, set_balance, get_transaction_history, and set_transaction_history methods as getters and setters for their respective variables set _balance should assert that whatever balance is being set is greater than -1 deposit and withdraw should assert that whatever amount that's given is greater than 0 All three should ensure that a number is passed, and if not then raise a TypeError along with a message withdraw should assert that whatever amount is being withdrawn is not greater than the balance The transaction_history variable should be a list that records every transaction that is made (IE, when an amount is deposited, append the deposited amount, when an amount is withdrawn, append the negative withdrawn amount) get_avg_transaction should first assert that the transaction_history is not empty. From there it should cycle through the history, adding up all of the numbers, and then find and return the average Use the file provided to check your work. Your output should look like this: Creating the bank account: rror: Not greater than You must enter a number etting the average transactions (first time) Error: No transactions have been made Error: Not greater than e You must enter a number ithdrawing money Error: Not greater than e You must enter a number etting the average transactions (second time) 50.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions