Ultimately, I am trying to accomplish the calculation of a number that gives me back 3 decimal places, and round it to 2 decimal places. What I have, is thus:
total = 175
tax = .0875
total += total * tax # giving me my desired total
print total
>>> 190.3125
rounded = round(total, 2) # giving me my desired decimal place
print rounded
>>> 190.31
I was thinking of doing the total
and rounded
line in one, but it looks jumbled...
Here is what I feel is the fastest way, but does not look as readable as I would like:
total = round((total + (total*tax)), 2)
print total
>>> 190.31
EDIT
Thank you guys for the input in the comments. It seems time is clearly not something to stress here & I am going to run with rounded = round(total, 2)
for my code. Thanks again!