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)

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

There is also format()

>>> p = 4.1895030939393
>>> print("Your total including tax is {:.2f}.".format(p))
Your total including tax is 4.19.

If you really want 4.18 you can try ...

p = 4.1895030939393

print(round(p-0.005, 2))

or

   print(int(p*100)/100.)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.