[Tutor] Ingenious script (IMO)
Dick Moores
rdm at rcblue.com
Sat Aug 11 13:24:06 CEST 2007
At 04:11 AM 8/11/2007, Dick Moores wrote:
>I was just about finished with a script that would tell the clerk
>how to give the change to the customer, when I discovered that the
>above script computes the wrong amount of change in certain
>situations. It works fine if the customer tenders only bills and no
>change, but that's not realistic. For example, if the cost is $1.78
>the customer may well tender $2.03 so he can get a quarter back
>rather than 2 dimes and 2 pennies. But the script in that case will
>compute change of 24 cents! Try it out. I've put the same script on
>the web, but deleted the line that I'd left in by mistake, "print coinCount".
Sorry. Forgot to include the link.
<http://www.rcblue.com/Misc/changeMakerKent0-a.py>
>So, does this mean I should use the decimal module? Or is there
>another way to fix the problem?
>
>Thanks,
>
>Dick
More information about the Tutor
mailing list