Hello
I have created the following code but would like the program to include two decimal places in the amounts displayed to the user. How can I add this?
My code:
# Ask user to enter purchase price
purchasePrice = input ('Enter purchase amount and then press the enter key $')
I have created the following code but would like the program to include two decimal places in the amounts displayed to the user. How can I add this?
My code:
# Ask user to enter purchase price
purchasePrice = input ('Enter purchase amount and then press the enter key $')
# Tax rates
stateTaxRate = 0.04
countrySalesTaxRate = 0.02
# Process taxes for purchase price
stateSalesTax = purchasePrice * stateTaxRate
countrySalesTax = purchasePrice * countrySalesTaxRate
# Process total of taxes
totalSalesTax = stateSalesTax + countrySalesTax
# Process total sale price
totalSalePrice = totalSalesTax + purchasePrice
# Display the data
print '%-18s %9d' % ('Purchase Price',purchasePrice)
print '%-18s %9d' % ('State Sales Tax',astateSalesTax)
print '%-18s %9d' % ('Country Sales Tax',countrySalesTax)
print '%-18s %9d' % ('Total Sales tax',totalSalesTax)
print '%-18s %9d' % ('Total Sale Price',totalSalePrice)
Thank you in advance for your help.
Lea
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor