Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.057 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'output': 0.05; 'assignment': 0.07; 'correct.': 0.07; 'variables': 0.07; 'subject:help': 0.08; 'alter': 0.09; 'defines': 0.09; 'function,': 0.09; 'spelling': 0.09; 'wrong,': 0.09; 'def': 0.12; '20)': 0.16; '20.00': 0.16; 'formatted': 0.16; 'imports': 0.16; 'parameters,': 0.16; 'received:74.208.4.195': 0.16; 'runs,': 0.16; 'demonstrate': 0.16; 'wrote:': 0.18; 'variable': 0.18; '(but': 0.19; 'programming': 0.22; 'import': 0.22; 'print': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'body,': 0.24; 'task': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'testing': 0.29; 'am,': 0.29; "doesn't": 0.30; 'heading': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'lines': 0.31; '(optional)': 0.31; 'apparently': 0.31; 'assert': 0.31; 'indentation': 0.31; 'parameters.': 0.31; 'this.': 0.32; 'supposed': 0.32; 'running': 0.33; 'problem.': 0.35; 'something': 0.35; 'but': 0.35; 'should': 0.36; 'error.': 0.37; 'expected': 0.38; 'displays': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'called': 0.40; 'how': 0.40; 'even': 0.60; 'transaction.': 0.60; 'ago,': 0.61; 'deposit': 0.61; 'till': 0.61; 'balance': 0.61; "you're": 0.61; "you'll": 0.62; 'complete': 0.62; 'making': 0.63; 'email addr:gmail.com': 0.63; 'name': 0.63; 'more': 0.64; 'income': 0.65; 'account': 0.65; 'subject:account': 0.65; 'within': 0.65; 'details,': 0.68; 'body.': 0.68; 'received:74.208': 0.68; 'below.': 0.71; 'money': 0.72; 'account.': 0.80; '500.00': 0.84; 'ledger': 0.84; 'proposal.': 0.84; 'subject:balance': 0.84; 'vodafone': 0.84; 'euros': 0.91; 'subject:urgent': 0.91; 'relating': 0.93; 'serious': 0.97 Date: Tue, 26 Mar 2013 06:56:13 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: JES account balance function help urgent! References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:i05/fdJtugycS4AKnjkYtQ1PEc7eMVB84+/KwfCuCwx XQOPk9KCCONoS8eULdyTS2Dtnogw37btPILWUC1JvXDb+6hi43 GMRLSiH9TsuDj0kBTQMIza7x1LUdAUatOZMxOY3lxc2EmvEfAO +cqlLBs6NkGzBr0AerQf3gr9tx9xxi3pnnpBj5nheXOR3hm2FB bIVqUfjzA+bfVOLTBuD5CWL+wIvvqhB7N511mPA6MpvtXhUqAe h5GXJtPlSeL21hhzf0GVhBB7Q8bSBiTVDaWm+01Ibva4tnWWgR p3Mrq9e366cfHJPgo66nbWV7hiVl+wnoQXejzld2Zcfxdpslg= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364295392 news.xs4all.nl 6890 [2001:888:2000:d::a6]:36356 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41878 On 03/26/2013 06:30 AM, kidoman3@gmail.com wrote: > I am supposed to complete the following five functions, i have no idea how to do this. I will greatly appreciate any help > > The following five functions allow you to maintain the running balance of an account and print out lines relating to each transaction. > > You'll also need a global variable (balance?) to maintain the running balance of the account. > > 1. def setBalance(amt): # Defines (but doesn't print) the value of the account balance > > 2. def printBalance(): # Displays current balance as a money value with a heading > > 3. def printLedgerLine(date, amount, details): # with items (and the balance) spaced and formatted > > 4. def deposit (date, details, amount): # Alter the balance and print ledger line > > 5. def withdraw(date, details, amount): # Alter the balance and print ledger line > > Your task is to: > complete the five (very short) functions by creating the code for the body of each function, and > demonstrate that you code works by calling the functions, as is demonstrated below. > > So when these functions are called > e.g. > > setBalance(500) > printBalance() > withdraw("17-12-2012", "BP - petrol", 72.50) > withdraw("19-12-2012", "Countdown", 55.50) > withdraw("20-12-2012", "munchies", 1.99) > withdraw("22-12-2012", "Vodafone", 20) > deposit ("23-12-2012", "Income", 225) > withdraw("24-12-2012", "Presents", 99.02) > printBalance() > The output is something like this: > > Current Balance is $ 500.00 > 17-12-2012 BP - petrol $ 72.50 $ 427.50 > 19-12-2012 Countdown $ 55.50 $ 372.00 > 20-12-2012 munchies $ 1.99 $ 370.01 > 22-12-2012 Vodafone $ 20.00 $ 350.01 > 23-12-2012 Income $ 225.00 $ 575.01 > 24-12-2012 Presents $ 99.02 $ 475.99 > Current Balance is $ 475.99 > > So far i got: > def setBalance(amount): > global balance > assert isinstance(amount,numbers.number) > balance = euros > printNow(balance) > > Im not sure whats wrong, i only started programming a week ago, im so lost, please help me with this assignment > thnx > I'm not sure how literally to take your proposal. You have no indentation in the function body, so that's one serious problem. And you're apparently calling printNow() from within that function, which is NOT what was called for. And the function takes "amount" as its parameter, but then uses 'euros' in the body. That's a big spelling error. You're also going to need to import numbers, if you want that isinstance to work. The layout of your code should be something like: shebang line (optional) imports global variables def's testing code (supplied by instructor) Write all the functions, making sure each takes the expected parameters, even if the function does nothing more than print its name and parameters. Then when the code runs, refine the function bodies till they're all correct. -- DaveA