Note that there are some explanatory texts on larger screens.

plurals
  1. PORounding in Python
    primarykey
    data
    text
    <p>Hi everyone I am currently doing a school project and even my teacher is stumped. In Canada the penny has been removed so now all purchases are rounded to either 0 or 5. For example 5.53 would become 5.55 and 5.52 would become 5.50. I am trying to get my program to round like this, but I can't figure out how. I know how to round to decimal places, but I don't know how to round to specifics like this. Any help would be appreciated!</p> <p>Here is my code. The project is about making a program that a cashier would use in a coffee shop.</p> <pre><code>order = ['coffee', 'tea', 'hashbrown','jelly','cream','chocolate','glazed','sandwich','bagel','cookie','pannini'] quantity = ['0','0','0','0','0','0','0','0','0','0','0'] # coffee = $1 # Tea = $1.30 # hashbrown = $1.25 # all donuts = $1.50 # sandwich = $2.50 # bagel = $2 # cookie = $0.50 # pannini = $4 cashier = 1 total = 0 while cashier == 1: print "What did the customer order?" ordered = input () while ordered &gt; 10 or ordered &lt; 0: print "Do you want to input a valid order?" ordered = input () print "How many are being ordered?" quantityorder = input () quantity[ordered] = quantityorder print "Ordered",quantityorder,"",order[ordered],"!" if ordered == 0: ordered = 1.0 elif ordered == 1: ordered = 1.30 elif ordered == 2: ordered = 1.25 elif ordered == 3 or ordered == 4 or ordered == 5 or ordered == 6: ordered = 1.50 elif ordered == 7: ordered = 2.50 elif ordered == 8: ordered = 2 elif ordered == 9: ordered = 0.50 else: ordered = 4.0 price = ordered * quantityorder total = total + price print "Anything else?" cashier = input () #If the user inputs 1 then they can input another order if they didn't put in 1 then the program assumes that it is the end of a customers order print "Your total is $", total * 1.13,"!" total = total * 1.13 print print "How much money was given?" print money = input ()* 1.0 while money &lt; total: print "Please input a valid number!" money = input () print "The change should be $",money - total,"!" </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload