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


Groups > comp.lang.python > #106016

Re: Calculate Bill

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Calculate Bill
Date Wed, 30 Mar 2016 10:34:23 +1100
Lines 33
Message-ID <mailman.171.1459294472.28225.python-list@python.org> (permalink)
References <ba29ab8f-1076-4a00-8b2e-b4bbe0fbae60@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 4L0Vzoe3VqY/ZUlVWSGNYwx7ngP88VL8NIlVozQmfYDw==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'converts': 0.07; 'works.': 0.07; 'cc:addr:python-list': 0.09; 'python': 0.10; 'wed,': 0.15; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'parentheses': 0.16; 'pizza': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'accepting': 0.18; 'input': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fix': 0.21; 'am,': 0.23; 'code,': 0.23; 'code.': 0.23; 'help.': 0.23; 'header:In-Reply-To:1': 0.24; 'appear': 0.26; 'message-id:@mail.gmail.com': 0.27; 'converting': 0.27; 'correct': 0.28; 'this.': 0.28; "i'm": 0.30; 'print': 0.30; 'that.': 0.30; 'work.': 0.30; 'code': 0.30; 'rules': 0.31; 'posting': 0.32; 'table': 0.32; 'problem': 0.33; 'source': 0.33; 'add': 0.34; 'that,': 0.34; 'received:google.com': 0.35; 'according': 0.36; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'thanks': 0.37; 'done.': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'someone': 0.38; 'thank': 0.38; 'does': 0.39; 'ever': 0.60; 'your': 0.60; 'press': 0.61; 'total': 0.62; '30,': 0.63; 'dont': 0.64; 'mar': 0.65; 'chrisa': 0.84; 'proves': 0.84; 'subject:Bill': 0.84; 'you;': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=PWGmmKQCiWuckJtrLYKX7kngiIatWeP87YbNEHFunTE=; b=ccrfCH0tCdqIAaMCbG2k/a5FNA/m65Am+5zdTkHqzicNV4N/tWUMXdEJO9uVpqumP5 nSimO+jBM5OMCg36aCcbuU/1Pbdg2ZRCmaPhoYxZM9SljEz0QUioFYCrSxapvWtAgwwO TQ/8NNxfcumqCQ+Oe+vLVp5Y8ksrjQ7dPmTqKiBBfDTiGUDlwvjc+Efz1++jpjvQdKM7 GEJKIZRXDiBbWVx00y64Sz5klfbY/9vqp0g2iKy3YTX9qBN/WfgiuskdSWbNc/pPwhIB lUUOfH1HdHYIOAAVIzwEQIxQtfv3w0ixhenrdJfoV9OE2grZ0aYM946um/VdZFwYTVHw csOg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=PWGmmKQCiWuckJtrLYKX7kngiIatWeP87YbNEHFunTE=; b=O9mk+MHNmMmZ7+erumL6ERCJdJC7+/t5e9mONP/Aps4J0GzlYfIsPe1tqvNwqucFIO /Fz0v7aExXEduUavTgUk4WCRZ45kOpiW3LY1He4uuoQi2Sai4yfCKynyxbCw0KQbSp7y +25kNTgMxQBaXlM0aTMBuJqjNDfSGCOV+HEyg1QHwiCx1FxFY1S05HPG+e7WWLIPzpGl gh9ciCyrefVuL8dqtbxP7TAX3Bgh2faSskLmkR8X17c2u/Xd49rAw5bJGocI/A+vDtOz Oe1ZMnj3vrmY0FYq5GDwbaW+SWrV+0GfCDgS/MCpWBKoIHkyixrHogTkZBoKm1G/4R9i 0DfQ==
X-Gm-Message-State AD7BkJJDtlYvH3XezYEqEMyT1yc2wgKrEf1kliZMQ9gNDwropjo8MyZy154XVad9wL0FyDxWmVkR+e5llF3akQ==
X-Received by 10.50.43.226 with SMTP id z2mr6288709igl.94.1459294463796; Tue, 29 Mar 2016 16:34:23 -0700 (PDT)
In-Reply-To <ba29ab8f-1076-4a00-8b2e-b4bbe0fbae60@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:106016

Show key headers only | View raw


On Wed, Mar 30, 2016 at 9:33 AM, Yum Di <nevinadias3@gmail.com> wrote:
> Hey.. this code works. However, i need it to calculate the total cost.
> I dont know how to do that. Can someone help me..
> thanks

It does indeed appear to work. And thank you for posting your current
code. However...

> print ("Welcome to Pizza Shed!")
>
> order = raw_input ("\n\nPLEASE PRESS ENTER TO ORDER." )
>
> tablenum = input ("Enter table number from 1-25 \n ")

This should never be done. Do not do this. Your use of raw_input
proves that you're using Python 2, and in Python 2, never ever ever
use input(). There are two solutions:

1) Use raw_input everywhere
2) Use Python 3, and add parentheses to the few print() calls that
don't have them.

Either way, the correct fix also involves accepting *strings* from the
keyboard, and then converting them. The problem with input() is that
it automatically converts what the user types, according to the rules
of source code; you almost never want this. For example, entering 08
will result in an error, but 08.50 is the same as 8.50.

After that, you can start looking at the totals. But I'm not going to
write the code for you; you can start writing code, and when you get
stuck, come and ask for help.

ChrisA

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


Thread

Calculate Bill Yum Di <nevinadias3@gmail.com> - 2016-03-29 15:33 -0700
  Re: Calculate Bill Chris Angelico <rosuav@gmail.com> - 2016-03-30 10:34 +1100
  Re: Calculate Bill Steven D'Aprano <steve@pearwood.info> - 2016-03-30 11:50 +1100
  Re: Calculate Bill BartC <bc@freeuk.com> - 2016-03-30 11:19 +0100

csiph-web