Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100324 > unrolled thread
| Started by | Harbey Leke <idowuolawale@gmail.com> |
|---|---|
| First post | 2015-12-12 01:05 -0800 |
| Last post | 2016-03-05 13:27 +0100 |
| Articles | 9 on this page of 109 — 43 participants |
Back to article view | Back to comp.lang.python
Need help on a project To :"Create a class called BankAccount with the following parameters " Harbey Leke <idowuolawale@gmail.com> - 2015-12-12 01:05 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2015-12-12 20:21 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Harbey Leke <idowuolawale@gmail.com> - 2015-12-12 02:09 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2015-12-12 21:17 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Harbey Leke <idowuolawale@gmail.com> - 2015-12-12 02:27 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Harbey Leke <idowuolawale@gmail.com> - 2015-12-12 02:29 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Warrick <kwpolska@gmail.com> - 2015-12-12 11:37 +0100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Steven D'Aprano <steve@pearwood.info> - 2015-12-12 23:32 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " mkatietola@gmail.com - 2015-12-12 09:37 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " malitician@gmail.com - 2015-12-18 19:15 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-19 14:47 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " malitician@gmail.com - 2015-12-19 15:19 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-20 00:41 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Michael Torrie <torriem@gmail.com> - 2015-12-19 18:09 -0700
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-25 15:08 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-25 15:09 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Erik <python@lucidity.plus.com> - 2015-12-26 00:01 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Cameron Simpson <cs@zip.com.au> - 2015-12-26 11:09 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-25 18:04 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Larry Hudson <orgnut@yahoo.com> - 2015-12-25 20:02 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " malitician@gmail.com - 2015-12-26 00:47 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-25 18:36 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-26 02:38 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-26 03:23 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Cameron Simpson <cs@zip.com.au> - 2015-12-27 07:20 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-27 07:02 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Erik <python@lucidity.plus.com> - 2015-12-27 15:26 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-27 12:26 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Prince Udoka <princeudo52@gmail.com> - 2015-12-27 12:32 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-27 12:54 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Erik <python@lucidity.plus.com> - 2015-12-27 21:42 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Cameron Simpson <cs@zip.com.au> - 2015-12-28 14:32 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-20 01:51 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " anyanwuchukwuemeka9@gmail.com - 2016-03-19 14:40 -0700
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Joel Goldstick <joel.goldstick@gmail.com> - 2016-03-19 18:03 -0400
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-19 22:24 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Ben Finney <ben+python@benfinney.id.au> - 2016-03-20 11:26 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-20 11:04 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2015-12-20 22:29 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " jeanbigboute@gmail.com - 2015-12-25 20:15 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-26 01:52 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-24 04:39 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-24 11:57 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-24 04:59 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2015-12-25 00:10 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-24 06:17 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2015-12-25 01:39 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " malitician@gmail.com - 2015-12-24 11:36 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Tim Chase <python.list@tim.thechases.com> - 2015-12-24 14:48 -0600
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " malitician@gmail.com - 2015-12-26 01:01 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Erik <python@lucidity.plus.com> - 2015-12-24 21:09 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Joel Goldstick <joel.goldstick@gmail.com> - 2015-12-24 10:47 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2015-12-24 11:14 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Grant Edwards <invalid@invalid.invalid> - 2015-12-24 17:30 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Gene Heskett <gheskett@wdtv.com> - 2015-12-24 13:51 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2015-12-24 14:09 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-24 18:55 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-12-26 11:36 +1300
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Grant Edwards <invalid@invalid.invalid> - 2015-12-31 16:46 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2015-12-25 03:31 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " princeudo52@gmail.com - 2015-12-25 15:05 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " xaviertim017@gmail.com - 2016-01-01 15:15 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-28 01:25 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Prince Udoka <princeudo52@gmail.com> - 2015-12-28 01:29 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Prince Udoka <princeudo52@gmail.com> - 2015-12-28 01:39 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " homiemusa@gmail.com - 2016-01-11 13:22 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Prince Udoka <princeudo52@gmail.com> - 2015-12-28 01:34 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Ben Finney <ben+python@benfinney.id.au> - 2015-12-28 20:41 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Cameron Simpson <cs@zip.com.au> - 2015-12-29 09:29 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-29 00:49 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Cameron Simpson <cs@zip.com.au> - 2015-12-29 21:48 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-29 04:39 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " homiemusa@gmail.com - 2016-01-11 14:07 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-11 19:46 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Prince Udoka <princeudo52@gmail.com> - 2015-12-28 23:35 +0100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " phatsammhiel@gmail.com - 2016-01-13 05:27 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Ben Finney <ben+python@benfinney.id.au> - 2015-12-28 20:38 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2015-12-28 01:53 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Joel Goldstick <joel.goldstick@gmail.com> - 2015-12-28 07:32 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " botic <princeudo52@gmail.com> - 2015-12-28 14:10 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " phatsammhiel@gmail.com - 2016-01-13 05:28 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2016-01-14 00:37 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-13 09:43 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Tim Golden <mail@timgolden.me.uk> - 2016-01-13 15:23 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Andrew Ongko <andrew.ongko@gmail.com> - 2016-01-13 22:35 +0700
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " phatsammhiel@gmail.com - 2016-01-13 05:44 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " kasale.jacktone@gmail.com - 2016-01-14 03:50 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-28 14:27 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Won Chang <princeudo52@gmail.com> - 2015-12-30 10:21 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Joel Goldstick <joel.goldstick@gmail.com> - 2015-12-30 15:06 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Joel Goldstick <joel.goldstick@gmail.com> - 2015-12-30 15:11 -0500
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " acushla4real@gmail.com - 2016-01-08 08:37 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " ifeanyioprah@gmail.com - 2016-01-11 21:26 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " ifeanyioprah@gmail.com - 2016-01-11 21:30 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " ifeanyioprah@gmail.com - 2016-01-11 21:33 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " ifeanyioprah@gmail.com - 2016-01-11 21:33 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " chetam.chetzy@gmail.com - 2016-03-13 17:17 -0700
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2016-03-14 11:40 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " MRAB <python@mrabarnett.plus.com> - 2016-03-14 00:57 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Chris Angelico <rosuav@gmail.com> - 2016-03-14 12:02 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Ben Finney <ben+python@benfinney.id.au> - 2016-03-14 12:08 +1100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " BartC <bc@freeuk.com> - 2016-03-14 01:33 +0000
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " xaviertim017@gmail.com - 2016-01-01 16:24 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " mrkimanindegwa@gmail.com - 2016-01-11 23:21 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lee <malitician@gmail.com> - 2016-01-12 05:20 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " bonfaceo3@gmail.com - 2016-01-13 03:14 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " lucasfrank254@gmail.com - 2016-03-04 23:41 -0800
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Peter Otten <__peter__@web.de> - 2016-03-05 10:07 +0100
Re: Need help on a project To :"Create a class called BankAccount with the following parameters " "Albert Visser" <albert.visser@gmail.com> - 2016-03-05 13:27 +0100
Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2016-03-14 12:08 +1100 |
| Subject | Re: Need help on a project To :"Create a class called BankAccount with the following parameters " |
| Message-ID | <mailman.84.1457917741.12893.python-list@python.org> |
| In reply to | #104792 |
chetam.chetzy@gmail.com writes: > Hello, I have this same assignment to create Bank account and I am new > to python. Welcome to Python! If you have an assignment, that implies you are working through a course and you have received enough teaching to attempt the task yourself. > please help me out. Apply your existing Python knowledge – you've been learning it in your course, right? – to run the test suite provided. Follow this procedure. * Run the test suite. * Observe what tests fail. If they all run and all pass, you're done. * Write just enough of the BankAccount class that it changes the behaviour of at least one test case. * Repeat from the top, until all the test cases pass. If you have questions: * Please provide a complete example (so that we can also run the same code), * Which is very small (so it's easy to discuss), * and ask specific questions about what it's doing and why that doesn't meet your expectation. -- \ “Kissing a smoker is like licking an ashtray.” —anonymous | `\ | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2016-03-14 01:33 +0000 |
| Subject | Re: Need help on a project To :"Create a class called BankAccount with the following parameters " |
| Message-ID | <nc547f$s4c$1@dont-email.me> |
| In reply to | #104792 |
On 14/03/2016 00:17, chetam.chetzy@gmail.com wrote:
> 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
I've never used classes and stuff much so I gave it a go. (But I
wouldn't submit this if it's an assignment).
class ac:
balance=0
def __init__(self,openbal):
if openbal>0:
self.balance=openbal
print ("Opened account; opening balance",self.balance)
else:
print ("Invalid opening balance:",openbal)
def payin(self,amount):
if amount>0:
self.balance+=amount
print ("Paid in:",amount," New balance:",self.balance)
return 1
else:
print ("Paying in invalid sum",amount)
return 0
def takeout(self,amount):
if amount<=0:
print ("Invalid withdrawal amount",amount)
return 0
elif amount>self.balance:
print ("Not enough funds")
return 0
else:
self.balance-=amount
print ("Paid out:",amount," New balance:",self.balance)
return 1
x=ac(100)
x.payin(34)
x.takeout(70)
x.takeout(1000000)
--
Bartc
[toc] | [prev] | [next] | [standalone]
| From | xaviertim017@gmail.com |
|---|---|
| Date | 2016-01-01 16:24 -0800 |
| Message-ID | <6299b5ff-48af-4a7b-b51c-b2f9fd26f047@googlegroups.com> |
| In reply to | #100324 |
On Saturday, December 12, 2015 at 10:05:29 AM UTC+1, Harbey Leke wrote:
> 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
>
> Please i need help on this i am a beginer into python programming.
>
>
> Also below is a test case given for this project
>
>
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
> def setUp(self):
> self.my_account = BankAccount(90)
>
> def test_balance(self):
> self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')
>
> def test_deposit(self):
> self.my_account.deposit(90)
> self.assertEqual(self.my_account.balance, 180, msg='Deposit method inaccurate')
>
> def test_withdraw(self):
> self.my_account.withdraw(40)
> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method inaccurate')
>
> def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", msg='Invalid transaction')
>
> def test_sub_class(self):
> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No true subclass of BankAccount')
Thank God for this group, its a very helpful. It turns out i had a correct code all the while. i found out that the "line 23 test" failed because of the case sensitivity.
i used - return ("Invalid Transaction")
instead of
return ("invalid transaction")
Notice the "i" and "t"
Thanks again
[toc] | [prev] | [next] | [standalone]
| From | mrkimanindegwa@gmail.com |
|---|---|
| Date | 2016-01-11 23:21 -0800 |
| Message-ID | <b577bb84-478c-41cd-a1ee-aa44e6a516bd@googlegroups.com> |
| In reply to | #100324 |
On Saturday, December 12, 2015 at 12:05:29 PM UTC+3, Harbey Leke wrote:
> 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
>
> Please i need help on this i am a beginer into python programming.
>
>
> Also below is a test case given for this project
>
>
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
> def setUp(self):
> self.my_account = BankAccount(90)
>
> def test_balance(self):
> self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')
>
> def test_deposit(self):
> self.my_account.deposit(90)
> self.assertEqual(self.my_account.balance, 180, msg='Deposit method inaccurate')
>
> def test_withdraw(self):
> self.my_account.withdraw(40)
> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method inaccurate')
>
> def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", msg='Invalid transaction')
>
> def test_sub_class(self):
> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No true subclass of BankAccount')
I would try.
class BankAccount:
def __init__(self,balance):
self.balance=balance
def deposit(self):
print("Please enter ammount to deposit")
dep=input()
global depbalance
depbalance=int(self.balance)+int(dep)
print("New balance is",depbalance)
def withdraw(self):
print("Please enter ammount to withdraw")
withd=input()
if int(withd) > int(depbalance):
print("Invalid Transaction")
else:
withbalance= depbalance-int(withd)
print("New balance after widthdrawal is",withbalance)
myAccount=BankAccount(0)
myAccount.deposit()
myAccount.withdraw()
class minimumBalanceAccount(BankAccount):
def msg(self):
print("This is a sub class")
mini=minimumBalanceAccount(0)
mini.msg()
mini.deposit()
mini.withdraw()
It may not be as fancy.
Although i dont understand the relevance of the test part in your question
[toc] | [prev] | [next] | [standalone]
| From | lee <malitician@gmail.com> |
|---|---|
| Date | 2016-01-12 05:20 -0800 |
| Message-ID | <33746645-80d7-4441-99dd-4e41e6a5816b@googlegroups.com> |
| In reply to | #100324 |
You're still struggling with this question because you didn't take your time to read the previous comments here , the solution to this and other question has being posted long ago before new year here , just read previous comments. Remember don't use print , instead use return .
[toc] | [prev] | [next] | [standalone]
| From | bonfaceo3@gmail.com |
|---|---|
| Date | 2016-01-13 03:14 -0800 |
| Message-ID | <3643bf28-dad3-48ca-9dcd-9581049415c2@googlegroups.com> |
| In reply to | #100324 |
On Saturday, December 12, 2015 at 12:05:29 PM UTC+3, Harbey Leke wrote: > 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 > > Please i need help on this i am a beginer into python programming. > > > Also below is a test case given for this project > > > import unittest > class AccountBalanceTestCases(unittest.TestCase): > def setUp(self): > self.my_account = BankAccount(90) > > def test_balance(self): > self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid') > > def test_deposit(self): > self.my_account.deposit(90) > self.assertEqual(self.my_account.balance, 180, msg='Deposit method inaccurate') > > def test_withdraw(self): > self.my_account.withdraw(40) > self.assertEqual(self.my_account.balance, 50, msg='Withdraw method inaccurate') > > def test_invalid_operation(self): > self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", msg='Invalid transaction') > > def test_sub_class(self): > self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No true subclass of BankAccount') lee is right go through the comment thread you will get what you are looking for
[toc] | [prev] | [next] | [standalone]
| From | lucasfrank254@gmail.com |
|---|---|
| Date | 2016-03-04 23:41 -0800 |
| Message-ID | <4a937ead-4e40-4d20-8514-27b6145dd27f@googlegroups.com> |
| In reply to | #100324 |
On Saturday, December 12, 2015 at 1:05:29 AM UTC-8, Harbey Leke wrote:
> 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
>
> Please i need help on this i am a beginer into python programming.
>
>
> Also below is a test case given for this project
>
>
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
> def setUp(self):
> self.my_account = BankAccount(90)
>
> def test_balance(self):
> self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')
>
> def test_deposit(self):
> self.my_account.deposit(90)
> self.assertEqual(self.my_account.balance, 180, msg='Deposit method inaccurate')
>
> def test_withdraw(self):
> self.my_account.withdraw(40)
> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method inaccurate')
>
> def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", msg='Invalid transaction')
>
> def test_sub_class(self):
> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No true subclass of BankAccount')
my solution is:
class BankAccount(object):
def __init__(self, initial_balance):
self.balance = initial_balance
def deposit(self, amount):
self.balance +=amount
def withdraw(self, amount):
if self.balance>= amount:
self.balance -= amount
else:
return invalid transaction
a1 = BankAccount (90)
a1.deposit(90)
a1.withdraw(40)
a1.withdraw(1000)
class MinimumBalanceAccount(BankAccount):
def __init__(self):
BankAccount.__init__(self,minimum_balance)
self.minimum_balance = minimum_balance
my_account = BankAccount(90)
my_account.withdraw(40)
print my_account.balance
It keeps alerting me that,"Error running your script".Where might I have gone wrong?Please help..
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-03-05 10:07 +0100 |
| Subject | Re: Need help on a project To :"Create a class called BankAccount with the following parameters " |
| Message-ID | <mailman.220.1457168860.20602.python-list@python.org> |
| In reply to | #104085 |
lucasfrank254@gmail.com wrote: > On Saturday, December 12, 2015 at 1:05:29 AM UTC-8, Harbey Leke wrote: >> 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 >> >> Please i need help on this i am a beginer into python programming. >> >> >> Also below is a test case given for this project >> >> >> import unittest >> class AccountBalanceTestCases(unittest.TestCase): >> def setUp(self): >> self.my_account = BankAccount(90) >> >> def test_balance(self): >> self.assertEqual(self.my_account.balance, 90, msg='Account Balance >> Invalid') >> >> def test_deposit(self): >> self.my_account.deposit(90) >> self.assertEqual(self.my_account.balance, 180, msg='Deposit method >> inaccurate') >> >> def test_withdraw(self): >> self.my_account.withdraw(40) >> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method >> inaccurate') >> >> def test_invalid_operation(self): >> self.assertEqual(self.my_account.withdraw(1000), "invalid >> transaction", msg='Invalid transaction') >> >> def test_sub_class(self): >> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), >> msg='No true subclass of BankAccount') > > my solution is: > > class BankAccount(object): > def __init__(self, initial_balance): > self.balance = initial_balance > def deposit(self, amount): > self.balance +=amount > def withdraw(self, amount): > if self.balance>= amount: > self.balance -= amount > else: > return invalid transaction > a1 = BankAccount (90) > a1.deposit(90) > a1.withdraw(40) > a1.withdraw(1000) > class MinimumBalanceAccount(BankAccount): > def __init__(self): > BankAccount.__init__(self,minimum_balance) > self.minimum_balance = minimum_balance > my_account = BankAccount(90) > my_account.withdraw(40) > print my_account.balance > > > It keeps alerting me that,"Error running your script".Where might I have > gone wrong?Please help.. When you run the above code as a script on your own machine, i. e. if the file is called bank.py you type python3 bank.py on the commandline (if you are using Idle, you can hit F5 instead), what happens? The output should give you a hint about what's wrong and where in the script the problem occurs. This output is called "traceback", and if you cannot make sense of it, come back here to ask, but don't forget to include the traceback into your post. Don't paraphrase, use cut and paste.
[toc] | [prev] | [next] | [standalone]
| From | "Albert Visser" <albert.visser@gmail.com> |
|---|---|
| Date | 2016-03-05 13:27 +0100 |
| Message-ID | <mailman.223.1457180842.20602.python-list@python.org> |
| In reply to | #104085 |
On Sat, 05 Mar 2016 08:41:39 +0100, <lucasfrank254@gmail.com> wrote: > On Saturday, December 12, 2015 at 1:05:29 AM UTC-8, Harbey Leke wrote: >> 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 >> >> Please i need help on this i am a beginer into python programming. >> >> >> Also below is a test case given for this project >> >> >> import unittest >> class AccountBalanceTestCases(unittest.TestCase): >> def setUp(self): >> self.my_account = BankAccount(90) >> >> def test_balance(self): >> self.assertEqual(self.my_account.balance, 90, msg='Account Balance >> Invalid') >> >> def test_deposit(self): >> self.my_account.deposit(90) >> self.assertEqual(self.my_account.balance, 180, msg='Deposit method >> inaccurate') >> >> def test_withdraw(self): >> self.my_account.withdraw(40) >> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method >> inaccurate') >> >> def test_invalid_operation(self): >> self.assertEqual(self.my_account.withdraw(1000), "invalid >> transaction", msg='Invalid transaction') >> >> def test_sub_class(self): >> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), >> msg='No true subclass of BankAccount') > > my solution is: > > class BankAccount(object): > def __init__(self, initial_balance): > self.balance = initial_balance > def deposit(self, amount): > self.balance +=amount > def withdraw(self, amount): > if self.balance>= amount: > self.balance -= amount > else: > return invalid transaction > a1 = BankAccount (90) > a1.deposit(90) > a1.withdraw(40) > a1.withdraw(1000) > class MinimumBalanceAccount(BankAccount): > def __init__(self): > BankAccount.__init__(self,minimum_balance) > self.minimum_balance = minimum_balance > my_account = BankAccount(90) > my_account.withdraw(40) > print my_account.balance > > > It keeps alerting me that,"Error running your script".Where might I have > gone wrong?Please help.. Most probably there's extra information available on the "Error running your script" message. You should examine that. Meanwhile, I think the line "return invalid transaction" provides a clue. -- Vriendelijke groeten / Kind regards, Albert Visser Using Opera's mail client: http://www.opera.com/mail/
[toc] | [prev] | [standalone]
Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]
Back to top | Article view | comp.lang.python
csiph-web