Write a program that asks the user for the price of an item, and then prints out a bill for the item. The bill includes the item price, the sales tax on the item, and the total amount paid by the customer. The sales tax is 5% of the item price. The total bill is the price of the item plus the sales tax.
The bill, if the item cost $99, would look like this:
Price $ 99.00 Sales tax 4.95 Total $ 103.95
This is what I have so far:
price = float(input("Price $")) tax = .05 salestax = (price*tax) total = ((price*tax)+ price) print("Sales tax ", salestax) print("Total $", total) Can someone help me with making the printed values have two decimal places?
Right now this is my output:
Price $99 Sales tax 4.95 Total $ 103.95 Clearly, the spacing is wrong, and not all of the dollar amounts have 2 decimal places
., and see if the second element exists. If so, count the digits and fill the remaining with0. If not, add.00to the end.print("Sales tax %.2f" % tax)