0

Hi, newbie to python here, I just wanted to ask how I can compute the after tax price and displaying only up to 2 decimal places. Like 4.1895030939393 will display only 4.18 without it rounding.

Here's what I've done so far

Original_Price = float(input('Please input the before-tax price : '))
Final_Price = (1.05*Original_Price)
print("Your total including tax is", Final_Price)

5
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by pyTony
Featured Replies
  • u can use the python built in function round() Original_Price = float(input('Please input the before-tax price : ')) Final_Price = (1.05*Original_Price) print("Your total including tax is", round(Final_Price, 2) ) you can find out more about it [here](http://docs.python.org/py3k/library/functions.html?highlight=round#round) Read More

1

u can use the python built in function round()

Original_Price = float(input('Please input the before-tax price : '))
Final_Price = (1.05*Original_Price)
print("Your total including tax is", round(Final_Price, 2) )

you can find out more about it here

0

There is also format()

>>> p = 4.1895030939393
>>> print("Your total including tax is {:.2f}.".format(p))
Your total including tax is 4.19.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.