What is wrong with this code and why it isn't working. class BankAccount: def init (self) :
Fantastic news! We've Found the answer you've been seeking!
Question:
What is wrong with this code and why it isn't working.
Transcribed Image Text:
class BankAccount: def init (self) : self.balance = 0.00 def deposit (self, amount) : self.balance += amount def withdraw (self, amount) : if self.balance >= amount: self.balance -= amount else: print ("Not enough money in the account. Withdrawal failed. ") def getBalance (self) : return self.balance a = BankAccount () print (a.getBalance ()) a.deposit (100.00) print (a.getBalance ()) a.withdraw (200.00) print (a.getBalance ()) a.withdraw (20.00) print (a.getBalance ()) class BankAccount: def init (self) : self.balance = 0.00 def deposit (self, amount) : self.balance += amount def withdraw (self, amount) : if self.balance >= amount: self.balance -= amount else: print ("Not enough money in the account. Withdrawal failed. ") def getBalance (self) : return self.balance a = BankAccount () print (a.getBalance ()) a.deposit (100.00) print (a.getBalance ()) a.withdraw (200.00) print (a.getBalance ()) a.withdraw (20.00) print (a.getBalance ())
Expert Answer:
Answer rating: 100% (QA)
YOU HAD NOT DECLARED INIT MEDHOT PROPERLY IN GIVEN CODE INSTED OF USE BEFORE AND AFTER init AS SHOWN ... View the full answer
Posted Date:
Students also viewed these programming questions
-
What is wrong with this statement? ( )-inx sima cos (tan x) cos cos
-
What is wrong with this scheme? To generate electricity without fuel, arrange a motor to operate a generator that will produce electricity that is stepped up with transformers so that the generator...
-
What is wrong with this "proof" that all horses are the same color? Let P(n) be the proposition that all the horses in a set of n horses are the same color. Inductive Step: Assume that P(k) is true,...
-
A company has 10,000 employees. Each employee is entitled to twenty days of paid holiday per calendar year. Up to five days of this entitlement may be carried forward and taken in the following year...
-
FBNH Enterprises, Inc. (FBNH), was a distributor of a product known as French Bronze Tablets. The purpose of the tablets was to allow a person to achieve an even tan without exposure to the sun. When...
-
What are the primary benefits of an ERP system? What are the primary risks?
-
Use the control variate method of Exercise 13 to determine the value of a 5 -month Asian call option on a stock with \(S_{0}=\$ 62, \sigma=20 \%\), and \(r=10 \%\) and a strike price of \(\$ 60\)....
-
Compute the payback period for each of these two separate investments (round the payback period to two decimals): a. A new operating system for an existing machine is expected to cost $250,000 and...
-
Amy wants to take the next five years off work to travel around the world. She estimates her annual cash needs at $34,000 (if she needs more, she will work odd jobs). Amy believes she can invest her...
-
All sales of Tracys Jeans and Uniforms (TJU) are made on credit. Sales are billed twice monthly, on the fifth of the month for the last half of the prior months sales and on the twentieth of the...
-
If the surplus on income ratio is only 15%, and the surplus on fund employed is only 26%. Is this two percentage hight or low?
-
From the following September 2022 transactions for K Pullen, you are required to: process the transactions in the accounting equation format enter next to each amount whether it is a debit or a...
-
You are required to process the following transactions for January made by D Brad in the accounting equation format. Note next to each transaction the alphabetical prefix and next to each amount...
-
You are required to prepare a trial balance as at 13 September 2022, using the general ledger for P Barrack prepared in answering question 4.9, where periodic inventory applied. Question 4.9 Refer...
-
From the following September 2022 transactions for K Pullen you are required to: a prepare general journals using the comparative general journal format in the Workbook for both perpetual and...
-
You are required to prepare a trial balance as at 13 September 2022, using the general ledger for P Barrack prepared in answering question 4.8, where perpetual inventory was used. Question 4.8 Refer...
-
Equation yields 82 (w) = -wg(w) for the Fourier transform of the second derivative of f(x). The condition f(x) 0 for x may be relaxed slightly. Find the least restrictive condition for the preceding...
-
The activities listed in lines 2125 serve primarily as examples of A) Underappreciated dangers B) Intolerable risks C) Medical priorities D) Policy failures
-
With reference to Exercise 4.5, find an expression for the distribution function \(F(x)\) of the random variable. Data From Exercise 4.5 k 4.5 Given that f(x): = is a probability distribution for 2x...
-
Given that \(f(x)=\frac{k}{2^{x}}\) is a probability distribution for a random variable that can take on the values \(x=\) \(0,1,2,3\), and 4 , find \(k\).
-
Check whether the following can define probability distributions and explain your answers. (a) \(f(x)=\frac{1}{4}\) for \(x=10,11,12,13\) (b) \(f(x)=\frac{2 x}{5}\) for \(x=0,1,2,3,4,5\) (c)...
Study smarter with the SolutionInn App