Sunday, 15 September 2013

python - having trouble adding multiple prices to a receipt -


I have trouble creating a receipt, it should be capable of taking several prices (as low as 1 and as infinitely ( If you want to go higher than that)) and be able to subtract from them, put tax on it and get the total. Well I can not figure out how many numbers to add to them.

  When you are finished, enter 1-I am receiving it (I have to remove (& lt ;,>) and put it (","). Price: 5.22 Enter the price of the item: Enter the price of the item 6.35: Your sub-sum is: "Your work subtotal on 0x0314C9C0" is your tax: "Performing a total on 0x0314C978": You have "0x0314CA08 But thanks to 2 items for shopping on the function "Total  

and this is coding for now. I

  print (" Qmart receipt ". (78, "-") printed ("when you are finished -1") DEP value (sub-total, item, value): counter = 0 while counter & lt; = item: sub-totals = (item + item) Sub-sum (): sub-sum = sum (input) def (): tax = sub-total * .065 DR total (total): total = sub-totals + tax counter = 0 value = input ("item value Enter: "True": True (input: "Enter the value of item:") Counter + = 1 if (value == -1): Print ("Your sub-Tata is:", Sub-totals) print ("Your tax is:", t Print ("You have purchased", Counter, "Item") Print ("Thank you for shopping Qmart")  

First: Use the return statement to return a result - Assign the value to the local function Doing so that you are not doing anything in Python. Def subtotal (): subtotal = sum (input) def (): tax = subtotal * .065 def total (): total = subtotal +

Def sub-sum instead of tax : Refund amount (input) by def (): return subtotal () * .065 DR total (): return subtotal (): < Second, and I have put the function of the function without any call in the snippet above it, () After the name of it - just the Naming function does not call it It also applies from print to the end Land - After each function name () will macerate .

EDIT: OP shows far more improvement in its bug as they are "still a bit confusing" (?!). Therefore, as I explained in a comment, sub-sum :

  def subtotal (change): return amount (value)  

( not using the input , which is the name of the underlying function for the list of prices!); And change the loop to start

  prices = [] while correct: value = float (input ("Enter the value of the item:")) If the value! = -1: Prices Price) << Code>  

I have also removed the waste variable counter - instead of using the last print lane (prices) .

Add all these changes to your code and press the O.P. Should have a working program No, OP, before you ask: I'm going to "put together" on your behalf No - Please do some working neurons by doing it manually Show: -)


No comments:

Post a Comment