Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106373
| Path | csiph.com!weretis.net!feeder4.news.weretis.net!ecngs!testfeeder.ecngs.de!81.171.118.63.MISMATCH!peer03.fr7!news.highwinds-media.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | anthony uwaifo <anthony.uwaifo55@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | i cant seem to figure out the error |
| Date | Sun, 3 Apr 2016 16:06:58 +0100 |
| Lines | 67 |
| Message-ID | <mailman.397.1459700384.28225.python-list@python.org> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de McIUmnDjmvuLlEv2I7Spew4Ipqti7w03xhiFmtfIZliQ== |
| Return-Path | <anthony.uwaifo55@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'skip:[ 20': 0.03; 'debug': 0.04; 'true,': 0.04; 'constructor': 0.07; 'false,': 0.07; 'skip:\\ 10': 0.07; 'skip:[ 30': 0.09; 'subclass': 0.09; 'subject:error': 0.11; 'accordingly.': 0.13; 'def': 0.13; 'everyone,': 0.15; '23,': 0.16; 'assignment.': 0.16; 'assigns': 0.16; 'bankaccount': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:r 90': 0.16; 'withdrawal': 0.16; 'integer': 0.18; 'skip:` 10': 0.18; 'skip:{ 20': 0.18; '>': 0.18; 'code.': 0.23; '8bit%:5': 0.23; 'written': 0.24; 'skip:" 20': 0.26; 'skip:m 30': 0.27; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'code:': 0.29; 'print': 0.30; 'code': 0.30; 'skip:& 30': 0.30; 'skip:[ 10': 0.31; 'error.': 0.31; 'skip:_ 10': 0.32; 'class': 0.33; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'skip:b 50': 0.35; 'there': 0.36; 'received:209.85': 0.36; 'skip:{ 10': 0.36; 'to:addr:python-list': 0.36; 'skip:& 10': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'skip:s 40': 0.38; 'subject:the': 0.39; 'takes': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'called': 0.40; 'your': 0.60; 'deposit': 0.61; 'balance': 0.64; '\xc2\xa0\xc2\xa0': 0.66; 'act': 0.67; '8bit%:27': 0.72 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=bcn+A6qs8xLCCMfKUaixqXIyL7y6IfN1WT2ceC90kj4=; b=QadFd1xDjq9/Pjq4jy5WUrDqgGvuq10gThynDDfm8qtGJiG/SJvz/WkzCW2zeoJpsa vupfmlmESQVn6m0+9RtsK+aPI6nY5yaVBuXLj/oruGXqIiAuYOdlN2P02NnyzNdhOcnm 5wWWEYa9dG582rtUTfuVO70zBtnTA9r4vnMMCVTJokwifNb7w9Y30YppDMUdODZfypca jjlzSEMTnYZJGEm3ouiI9ZhNyrwVdvrGWDcG2WmfPiToUkjMFY9fW6GB3aOyUZTknJeZ SzfgnMB+163BxDNVaXYRAVtHqxf8SQx9uHHy+dOLSDmTmKMvX/g06wGlGPegrDw+dzWS pKKw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=bcn+A6qs8xLCCMfKUaixqXIyL7y6IfN1WT2ceC90kj4=; b=DKHGmTvfisURJNePZl9lYE9uyZYkqLVJ8AjzHpRZBA66F1aqHAkDvBxprgmsIsubAi 5vv7O2UnJXuWKx6+AhnzKjT1mSsP0to5Kx3IXiC+ozNwZy+ZF+S5XtDLqLCLsDz1fYY+ voTcNispu/bdpsZYqU6m8l2l9tVi9WNgOGlWqmCLx0Rkt9H2C1ZGdUA52FD8OhUXxnYU MsyY24BFdB3qpnWRbZKolvrYwqK9sMivqbCc0MtJuJ0NpBXedJscWtyTSFVBNScGAwsE M85mXDhTO6QyjA9Pe68E89XzykH6GMNrNkvm+yR5mWi0i2sLMbofEPR/MFAcFElr0Mc6 2Opg== |
| X-Gm-Message-State | AD7BkJLCrsOLrCsqUSj9IuWQAukSb5caNivbh38zaafZ2N5kW66HS9OnwZgoefzn86rf2bhZ3/NmZW1lvaY2QA== |
| X-Received | by 10.31.133.201 with SMTP id h192mr1900857vkd.102.1459696018882; Sun, 03 Apr 2016 08:06:58 -0700 (PDT) |
| X-Mailman-Approved-At | Sun, 03 Apr 2016 12:19:43 -0400 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Received-Bytes | 5960 |
| X-Received-Body-CRC | 4223682870 |
| Xref | csiph.com comp.lang.python:106373 |
Show key headers only | View raw
hi everyone,
please i need help with this assignment. I have written a code and i still
get an error. please help me debug my code.
instructions:
- 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
My code:
class BankAccount(object):
def __init__(self, balance):
self.balance = balance
def deposit(self, amount):
self.amount=amount
self.balance += amount
return self.balance
def withdraw(self, amount):
self.amount=amount
if(amount > self.balance):
return ("Amount greater than available balance.")
else:
self.balance -= amount
return self.balance
class MinimumBalanceAccount(BankAccount):
def __init__(self, minimum_balance):
BankAccount.__init__(self)
self.minimum_balance = minimum_balance
act = BankAccount(5)
act.deposit(400)
act.withdraw(200)
print act.balance
error message:
THERE IS AN ERROR/BUG IN YOUR CODE*Results: *
{"finished": true, "success": [{"fullName": "test_balance",
"passedSpecNumber": 1}, {"fullName": "test_deposit",
"passedSpecNumber": 2}, {"fullName": "test_sub_class",
"passedSpecNumber": 3}, {"fullName": "test_withdraw",
"passedSpecNumber": 4}], "passed": false, "started": true, "failures":
[{"failedSpecNumber": 1, "fullName": "test_invalid_operation",
"failedExpectations": [{"message": "Failure in line 23, in
test_invalid_operation\n
self.assertEqual(self.my_account.withdraw(1000), \"invalid
transaction\", msg='Invalid transaction')\nAssertionError: Invalid
transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, "time":
"0.000079"}}
205
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
i cant seem to figure out the error anthony uwaifo <anthony.uwaifo55@gmail.com> - 2016-04-03 16:06 +0100 Re: i cant seem to figure out the error Peter Pearson <pkpearson@nowhere.invalid> - 2016-04-03 18:18 +0000
csiph-web