Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101525 > unrolled thread

Need help with this asap.

Started byifeanyioprah@yahoo.com
First post2016-01-12 08:48 +0300
Last post2016-01-12 08:48 +0300
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Need help with this asap. ifeanyioprah@yahoo.com - 2016-01-12 08:48 +0300

#101525 — Need help with this asap.

Fromifeanyioprah@yahoo.com
Date2016-01-12 08:48 +0300
SubjectNeed help with this asap.
Message-ID<mailman.43.1452587147.13488.python-list@python.org>
Create a class called BankAccount
Create a constructor that takes in an integer and assigns this to a `balance` property.
Create a method called `deposit` that takes in cash deposit amount and updates the balance accordingly.
Create a method called `withdraw` that takes in cash withdrawal amount and updates the balance accordingly. if amount is greater than balance return `"invalid transaction"`
Create a subclass MinimumBalanceAccount of the BankAccount class.
This was my solution and I still got error. What should I do.
class BankAccount: 
    def __init__(self, initial_amount): 
        self.balance = initial_amount 
    def deposit(self, amount): 
        self.balance += amount 
    def withdraw(self, amount): 
        if self.balance>= amount: 
            self.balance  -=  amount 
        else: 
          print('invalid transaction') 
a1 = BankAccount (90) 
a1.deposit(90) 
a1.withdraw(40) 
a1.withdraw(1000) 
class MinimumBalanceAccount(BankAccount): 
    def __init__(self): 
        BankAccount.__init__(self) 

Please help me.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web