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


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

Need help on a project To :"Create a class called BankAccount with the following parameters "

Started byHarbey Leke <idowuolawale@gmail.com>
First post2015-12-12 01:05 -0800
Last post2016-03-05 13:27 +0100
Articles 20 on this page of 109 — 43 participants

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


Contents

  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 1 of 6  [1] 2 3 4 5 6  Next page →


#100324 — Need help on a project To :"Create a class called BankAccount with the following parameters "

FromHarbey Leke <idowuolawale@gmail.com>
Date2015-12-12 01:05 -0800
SubjectNeed help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<5ec1d759-a2ab-4193-a4aa-869c0bf0506c@googlegroups.com>
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')
  

[toc] | [next] | [standalone]


#100325 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromChris Angelico <rosuav@gmail.com>
Date2015-12-12 20:21 +1100
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.175.1449912091.12405.python-list@python.org>
In reply to#100324
On Sat, Dec 12, 2015 at 8:05 PM, Harbey Leke <idowuolawale@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
>
> Please i need help on this i am a beginer into python programming.

Start by creating a text file in which you will store your code. Then
create a class called BankAccount, and start adding methods to it.

Which part of this do you need help with?

If you're taking a course on Python programming, you should have met
these concepts. Go and read the course text and see if you can find
the information you need.

ChrisA

[toc] | [prev] | [next] | [standalone]


#100326 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromHarbey Leke <idowuolawale@gmail.com>
Date2015-12-12 02:09 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<e79deff0-89c6-4dbb-9825-ac0241d73e9b@googlegroups.com>
In reply to#100325
i need help with every part of the project, like a complete text of scripts for it, thrn i can practise with it on my own and then u can give me assignments to improve on 
thanks

[toc] | [prev] | [next] | [standalone]


#100327 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromChris Angelico <rosuav@gmail.com>
Date2015-12-12 21:17 +1100
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.176.1449915465.12405.python-list@python.org>
In reply to#100326
On Sat, Dec 12, 2015 at 9:09 PM, Harbey Leke <idowuolawale@gmail.com> wrote:
> i need help with every part of the project, like a complete text of scripts for it, thrn i can practise with it on my own and then u can give me assignments to improve on
> thanks

No.

You're the one taking the course; you write the code. If you get to
the point of having code that ought to do everything but, for reasons
you don't understand, doesn't, then you can post it here and ask for
help figuring things out. But we're not going to do your homework for
you.

ChrisA

[toc] | [prev] | [next] | [standalone]


#100328 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromHarbey Leke <idowuolawale@gmail.com>
Date2015-12-12 02:27 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<6f852b8c-5902-4639-a393-d3e5f3b1de88@googlegroups.com>
In reply to#100327
oh oh okay start it for me please
thanks or guide me about it then.

[toc] | [prev] | [next] | [standalone]


#100329 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromHarbey Leke <idowuolawale@gmail.com>
Date2015-12-12 02:29 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<fdcfa06e-04bd-4fc0-9f0a-c8a691bab981@googlegroups.com>
In reply to#100327
oh oh okay start it for me please
thanks or guide me about it then.

[toc] | [prev] | [next] | [standalone]


#100330 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromChris Warrick <kwpolska@gmail.com>
Date2015-12-12 11:37 +0100
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.177.1449916687.12405.python-list@python.org>
In reply to#100329
On 12 December 2015 at 11:29, Harbey Leke <idowuolawale@gmail.com> wrote:
> oh oh okay start it for me please
> thanks or guide me about it then.
> --
> https://mail.python.org/mailman/listinfo/python-list

class BankAccount(object):
    # your code goes here

Seriously: read the materials you got with your course, or the Python
tutorial and documentation at https://docs.python.org/ .

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

[toc] | [prev] | [next] | [standalone]


#100331

FromSteven D'Aprano <steve@pearwood.info>
Date2015-12-12 23:32 +1100
Message-ID<566c13e9$0$1583$c3e8da3$5496439d@news.astraweb.com>
In reply to#100324
On Sat, 12 Dec 2015 08:05 pm, Harbey Leke wrote:

> Create a class called BankAccount


class BankAccount:
    pass


That's easy. Unfortunately, that class does nothing, but at least it exists!
Now all you have to do is create *methods* of the class that do the work.

Here I give it a method called "display_balance" which prints the balance of
the account:

class BankAccount:
    def display_balance(self):
        bal = self.balance
        print(bal)


Notice that the method is indented inside the class.

Unfortunately, that method doesn't work yet. The problem is, the account
doesn't yet have a balance, so obviously trying to print it will fail.
First you need to do the next part of the assignment:


> .Create a constructor that takes in an integer and assigns this to a
> `balance` property.

A "constructor" is a special method that Python automatically used to create
new instances. (I hope you understand what instances are!) Python classes
have two constructor methods:

    __new__

    __init__

Notice that they both start and end with TWO underscores.

Chances are, you won't need to use __new__, you will probably use __init__
instead. (Technically, __init__ is an initializer method, not a
constructor, but most people don't care about the difference.) So you have
to write a method called "__init__" that takes an integer argument (don't
forget the "self" argument as well!) and assigns that to a balance
property.


Here is how you assign a value to a attribute called "name":

    self.name = "Harbey"


And an attribute called "number":

    self.number = 23


And an attribute called "address":


    self.address = "742 Evergreen Terrace Springfield"


See the pattern? How would you assign to an attribute called "balance"? Put
that *inside* the constructor method inside the class.



> .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"`


Again, you need to create two new methods. Remember, you create a method
with "def ..." and indent it inside the class. They must have a "self"
argument, plus whatever extra arguments the instructions above demand.

Here is how you would triple an attribute called "total":


    self.total = 3 * self.total


How would you add or subtract from "balance" instead?


I've given you most of the pieces you need to solve this problem. You just
need to assemble them into working code. Off you go, write some code, and
if you have any problems, show us what code you have written and ask for
help. Just don't ask us to do your assignment for you.




-- 
Steven

[toc] | [prev] | [next] | [standalone]


#100343

Frommkatietola@gmail.com
Date2015-12-12 09:37 -0800
Message-ID<b5841899-a2e9-4c78-853b-acfa24b38d5c@googlegroups.com>
In reply to#100331
Thank you so much Steven 
you've given me a really great head start 

[toc] | [prev] | [next] | [standalone]


#100609

Frommalitician@gmail.com
Date2015-12-18 19:15 -0800
Message-ID<c3ecc5bb-c1ed-45f2-8ddf-bcea1cb6bcd0@googlegroups.com>
In reply to#100324
good explanation Steven but can you please do more by  posting the exact code as it relate to the question please? 

[toc] | [prev] | [next] | [standalone]


#100612 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-12-19 14:47 +0000
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.59.1450536446.30845.python-list@python.org>
In reply to#100609
On 19/12/2015 03:15, malitician@gmail.com wrote:
> good explanation Steven but can you please do more by  posting the exact code as it relate to the question please?
>

Please show us the code that you've written and we'll help, we do not 
write code for you.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#100615 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

Frommalitician@gmail.com
Date2015-12-19 15:19 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<8b40be10-d859-418d-b6b6-f687463a4847@googlegroups.com>
In reply to#100612
you are absolutely correct Mark 
i'm a beginner in python and  from the original question and test case given above i wrote this 



class BankAccount(object):
    def __init__(self, initial_balance=0):
        self.balance = initial_balance
    def deposit(self, amount):
        self.balance +=amount
    def withdraw(self, amount):
        self.balance -= amount
my_account = BankAccount(90)
my_account.withdraw(1000)
if my_account.balance < 4:
    print('invalid transaction')
class MinimumBalanceAccount(BankAccount):
    def __init__(self, MinimumBalance=4):
        self.minbalance = MinimumBalance





after executing this i got this  TEST SOLUTION ERROR which i don't know what it means





{"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.000065"}}
-910
invalid transaction



SO please what is wrong with my code, does it not meet the requirement of the "test case" given above in the question? 
Thanks in advance

[toc] | [prev] | [next] | [standalone]


#100616 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-12-20 00:41 +0000
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.60.1450572097.30845.python-list@python.org>
In reply to#100615
On 19/12/2015 23:19, malitician@gmail.com wrote:
> you are absolutely correct Mark
> i'm a beginner in python and  from the original question and test case given above i wrote this
>
> class BankAccount(object):
>      def __init__(self, initial_balance=0):
>          self.balance = initial_balance
>      def deposit(self, amount):
>          self.balance +=amount
>      def withdraw(self, amount):
>          self.balance -= amount
> my_account = BankAccount(90)
> my_account.withdraw(1000)
> if my_account.balance < 4:
>      print('invalid transaction')
> class MinimumBalanceAccount(BankAccount):
>      def __init__(self, MinimumBalance=4):
>          self.minbalance = MinimumBalance
>
> after executing this i got this  TEST SOLUTION ERROR which i don't know what it means
>
> {"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.000065"}}
> -910
> invalid transaction
>
> SO please what is wrong with my code, does it not meet the requirement of the "test case" given above in the question?
> Thanks in advance
>

It's a start but you've still left things out.  If I run your code as 
given above it outputs "invalid transaction", exactly as expected.  So 
how are you running the code?  Where does the extra output you give 
above come from, presumably the "test case", whatever that might be?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#100617 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromMichael Torrie <torriem@gmail.com>
Date2015-12-19 18:09 -0700
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.61.1450574101.30845.python-list@python.org>
In reply to#100615
On 12/19/2015 05:41 PM, Mark Lawrence wrote:
> On 19/12/2015 23:19, malitician@gmail.com wrote:
>> you are absolutely correct Mark
>> i'm a beginner in python and  from the original question and test case given above i wrote this
>>
>> class BankAccount(object):
>>      def __init__(self, initial_balance=0):
>>          self.balance = initial_balance
>>      def deposit(self, amount):
>>          self.balance +=amount
>>      def withdraw(self, amount):
>>          self.balance -= amount
>> my_account = BankAccount(90)
>> my_account.withdraw(1000)
>> if my_account.balance < 4:
>>      print('invalid transaction')
 ^^^^^^^^^^^^^^^^^^
This code probably belongs in the withdraw() method.

>> class MinimumBalanceAccount(BankAccount):
>>      def __init__(self, MinimumBalance=4):
>>          self.minbalance = MinimumBalance
>>
>> after executing this i got this  TEST SOLUTION ERROR which i don't know what it means
>>
>> {"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.000065"}}
>> -910
>> invalid transaction
>>
>> SO please what is wrong with my code, does it not meet the requirement of the "test case" given above in the question?
>> Thanks in advance
>>
> 
> It's a start but you've still left things out.  If I run your code as 
> given above it outputs "invalid transaction", exactly as expected.  So 
> how are you running the code?  Where does the extra output you give 
> above come from, presumably the "test case", whatever that might be?

While the output is as we'd expect, the program's logic is probably
wrong.  Would not you want to put that logic in the withdraw method to
prevent an invalid transaction?

[toc] | [prev] | [next] | [standalone]


#100866 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

Fromprinceudo52@gmail.com
Date2015-12-25 15:08 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<f4ba76ec-7883-4a0b-aac3-dec17b557bc8@googlegroups.com>
In reply to#100617
Create a function manipulate_data that does the following
Accepts as the first parameter a string specifying the data structure to be used "list", "set" or "dictionary"
Accepts as the second parameter the data to be manipulated based on the data structure specified e.g [1, 4, 9, 16, 25] for a list data structure
Based off the first parameter

    return the reverse of a list or
    add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the resulting set
    return the keys of a dictionary.

[toc] | [prev] | [next] | [standalone]


#100867 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

Fromprinceudo52@gmail.com
Date2015-12-25 15:09 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<9b74e1e6-a28e-475d-b213-3a80e241773d@googlegroups.com>
In reply to#100617
#my solution is:
def manipulate_data(dic,dict_data = {'name':'prince','age':21,'sex':'male'}):
  return dict_data.keys()

def manipulate_data( alist, list_data = [2,8,16,23,14]):
  return list_data.reverse()

def manipulate_data(aset, set_data = {"bee","cee","dee"}):
  set_data = {"bee","cee","dee"}
  set_data.update("ANDELA","TIA","AFRICA")
  return dictionary_data
#please what is wrong with my code

[toc] | [prev] | [next] | [standalone]


#100868 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromErik <python@lucidity.plus.com>
Date2015-12-26 00:01 +0000
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.13.1451088102.11925.python-list@python.org>
In reply to#100867
Hi,

I appreciate that you've made an effort this time to write some code, 
but have you attempted to try to _execute_ any of this? [I can see that 
the answer must be "no"]

On 25/12/15 23:09, princeudo52@gmail.com wrote:
 > #my solution is:
 > def manipulate_data(dic,dict_data = 
{'name':'prince','age':21,'sex':'male'}):
 >    return dict_data.keys()
 >
 > def manipulate_data( alist, list_data = [2,8,16,23,14]):
 >    return list_data.reverse()
 >
 > def manipulate_data(aset, set_data = {"bee","cee","dee"}):
 >    set_data = {"bee","cee","dee"}
 >    set_data.update("ANDELA","TIA","AFRICA")
 >    return dictionary_data
 > #please what is wrong with my code

If you try to execute it (by writing a test that calls the functions), 
you will get errors. Those errors will help you to fix it. If you get to 
the point where there is an error you really can't work out for yourself 
then you can ask a specific question related to what it is you don't 
understand about the error.

It looks like you're just typing in something and sending it to the list 
first rather than the Python interpreter.

If you want to learn how to program well, then you need to learn how to 
interpret the compiler/parser error messages or exceptions you get and 
work out what is wrong for yourself. You can only do that by running 
your code.

I'll give you a hint - read the words of your assignment very carefully. 
It says "a function" (not "several functions") that "Accepts as the 
first parameter a string". Look at what it then says about the second 
parameter, based on that first parameter.

Work on it from there and when you get really stuck, post the code and 
the Python error you get and why you don't understand it (saying what 
you _think_ it means but why that doesn't help you would also be good).

E.

[toc] | [prev] | [next] | [standalone]


#100870 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromCameron Simpson <cs@zip.com.au>
Date2015-12-26 11:09 +1100
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<mailman.15.1451088591.11925.python-list@python.org>
In reply to#100867
On 25Dec2015 15:05, princeudo52@gmail.com <princeudo52@gmail.com> wrote:
>i have gotten the answer of that problem

Please include some context when posting to the list; there are many 
discussions and it is best to include a little more than the subject line in 
such things. It is also polite to post your working solution for the benefit of 
those who have assisted you, or for others with a similar problem.

Then two more messages in quick succession: this list is not an instant 
messaging system. Please try to post a single message, with your question and 
also what code you have already.

Regarding your actual question, commentry below the quoted text follows...

On 25Dec2015 15:08, princeudo52@gmail.com <princeudo52@gmail.com> wrote:
>Create a function manipulate_data that does the following
>Accepts as the first parameter a string specifying the data structure to be used "list", "set" or "dictionary"
>Accepts as the second parameter the data to be manipulated based on the data structure specified e.g [1, 4, 9, 16, 25] for a list data structure
>Based off the first parameter
>
>    return the reverse of a list or
>    add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the resulting set
>    return the keys of a dictionary.
>
>#my solution is:
>def manipulate_data(dic,dict_data = {'name':'prince','age':21,'sex':'male'}):
>  return dict_data.keys()
>
>def manipulate_data( alist, list_data = [2,8,16,23,14]):
>  return list_data.reverse()
>
>def manipulate_data(aset, set_data = {"bee","cee","dee"}):
>  set_data = {"bee","cee","dee"}
>  set_data.update("ANDELA","TIA","AFRICA")
>  return dictionary_data
>#please what is wrong with my code

The most obvious thing that is wrong it that you have 3 functions here with the 
same name. In Python that means: define the first function and bind it to the 
name "manipulate_data". Then define the second and bind it to the same name as 
the first, discarding the first function. The define the third and bind it to 
the same name again, discarding the second function.

Your task is asking for a _single_ function which behaves differently according 
to a parameter which tells it what kind of data is has been given, so you want 
a function which starts like this:

  def manipulate_data(kind, data):

and you are supposed to pass in the string "list", "set" or dictionary for the 
first parameter, and some corresponding list, set or dictionary as the second 
parameter. There should _not_ be default values for either of these.

Instead, your function should examine the "kind" parameter and decide what to 
do. So it would reasonably look like this (untested):

  def manipulate_data(kind, data):
    if kind == 'list':
      ... do stuff with data using it as a list ...
    elif kind == 'set':
      ... do stuff with data using it as a set ...
    if kind == 'dictionary':
      ... do stuff with data using it as a dictionary ...
    else:
      raise ValueError("invalid kind %r, expected 'list', 'set' or 'dictionary'" % (kind,))

Try starting with that and see how you go.

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#100874 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

Fromprinceudo52@gmail.com
Date2015-12-25 18:04 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<ec6d3be5-53c1-46e7-8f90-e0dca293af76@googlegroups.com>
In reply to#100870
#i have worked over 2hours only to get this: some-one help please
manipulate_data = []
item = {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}
manipulate_data.append(item)
for i in  reversed(manipulate_data):
    new = {"ANDELA", "TIA", "AFRICA"}
    def list_append(manipulate_data, new):
        manipulate_data.append(new)
        return new
        return dict.keys()
   

 print manipulate_data
#this is the instruction:
Create a function manipulate_data that does the following
Accepts as the first parameter a string specifying the data structure to be used "list", "set" or "dictionary"
Accepts as the second parameter the data to be manipulated based on the data structure specified e.g [1, 4, 9, 16, 25] for a list data structure
Based off the first parameter

    return the reverse of a list or
    add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the resulting set
    return the keys of a dictionary.

[toc] | [prev] | [next] | [standalone]


#100879 — Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

FromLarry Hudson <orgnut@yahoo.com>
Date2015-12-25 20:02 -0800
SubjectRe: Need help on a project To :"Create a class called BankAccount with the following parameters "
Message-ID<Bo2dnc074ub-jOPLnZ2dnUU7-IOdnZ2d@giganews.com>
In reply to#100874
On 12/25/2015 06:04 PM, princeudo52@gmail.com wrote:
> #i have worked over 2hours only to get this: some-one help please
> manipulate_data = []
[snip other incorrect nonsense...]
>
> #this is the instruction:
> Create a function manipulate_data that does the following
[snip...]

Let's start with your first mistake (because the rest is wrong because of this):

READ YOUR INSTRUCTIONS!
It says "Create a function..."

Your 'solution' creates a list.
A list is NOT a function.

      -=- Larry -=-

[toc] | [prev] | [next] | [standalone]


Page 1 of 6  [1] 2 3 4 5 6  Next page →

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


csiph-web