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


Groups > comp.lang.python > #51993

Re: Creating a running tally/ definitely new to this

Path csiph.com!usenet.pasdenom.info!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'assignment': 0.07; 'attribute': 0.07; 'methods,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; '(just': 0.16; 'order?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'responses.': 0.16; 'tally': 0.16; 'wrote:': 0.18; 'written': 0.21; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; 'fairly': 0.24; 'sort': 0.25; 'player': 0.26; 'certain': 0.27; 'header:X -Complaints-To:1': 0.27; 'appreciated.': 0.29; 'url:wiki': 0.31; 'class': 0.32; 'url:python': 0.33; 'running': 0.33; 'basic': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; "i'll": 0.36; 'url:org': 0.36; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'save': 0.62; "you've": 0.63; 'email addr:gmail.com': 0.63; 'assistance': 0.66; 'subject:this': 0.83; 'assets.': 0.84; 'game,': 0.84; 'homework': 0.84; 'pain': 0.84; 'step,': 0.84; 'dozen': 0.91; 'navigate': 0.91; 'thing,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Creating a running tally/ definitely new to this
Date Tue, 6 Aug 2013 02:15:30 +0000 (UTC)
References <9e9e6a5a-5f8e-46b4-91dc-757fc74348d9@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 174.32.174.32
User-Agent XPN/1.2.6 (Street Spirit ; Linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.226.1375755352.1251.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375755352 news.xs4all.nl 15881 [2001:888:2000:d::a6]:56523
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51993

Show key headers only | View raw


gratedmedia@gmail.com wrote:

>
> I currently working on a game, where I need to maintain a running tally of money, as the player makes purchases as they navigate thru game.   I not exactly sure how to do this in python.  I know it is a fairly basic step, nonetheless.  Any assistance would be greatly appreciated.  

(just to save you the pain later:
   http://wiki.python.org/moin/GoogleGroupsPython
)

So what have you written so far?  Is this a homework assignment and
you've been covering certain parts of Python in a certain order? Is it
part of learning some tutorial?

There are so many ways of accomplishing this sort of thing, that without
some constraints, there are a dozen reasonable responses.  I'll try one:

in the class Player, you make a pair of methods, purchase() and
income(), which manipulate the instance attribute assets.   Then you
make a property that returns the assets.



Class Player:
     ....
     def purchase(self, amount):
        self.assets -= amount
     def income(self, amount):
        self.assets += amount
     def wealth(self):
        return self.assets


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-05 18:01 -0700
  Re: Creating a running tally/ definitely new to this Joshua Landau <joshua@landau.ws> - 2013-08-06 02:56 +0100
    Re: Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-06 04:00 -0700
  Re: Creating a running tally/ definitely new to this Dave Angel <davea@davea.name> - 2013-08-06 02:15 +0000
    Re: Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-06 08:24 -0700
      Re: Creating a running tally/ definitely new to this Joshua Landau <joshua@landau.ws> - 2013-08-07 13:02 +0100

csiph-web