[Tutor] Want to keep to two decimal places for currency

Shelby Martin shelby.martin at gmail.com
Wed Oct 23 23:39:00 CEST 2013


I've looked online but I'm confused - I need to keep it so that the
following program limits the output to two decimal places since it deals in
currency.

How do I incorporate that into my current code below? The textbook I'm
using doesn't describe how to do that. Thanks in advance.


#Challenge Chapter 2
#Question number three

print("This program helps you to determine a tip amount of either")
print("15 or 20 percent.")

bill=float(input("\nHow much was your restaurant bill total (in dollars)?
"))

fifteen=float(bill*0.15)
twenty=float(bill*0.2)

print("\n15% tip = $", fifteen)
print("\n20% tip = $", twenty)

input("\n\nPress the enter key to exit.")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131023/2d0c0c9d/attachment.html>


More information about the Tutor mailing list