0

Hi, I have a question about the code in description. Why x*=1.07 is not the same as x+=x*7/100

https://code.sololearn.com/cF70MDsKE62H/?ref=app

9th Dec 2022, 9:44 PM
Roberto Moggia
Roberto Moggia - avatar
6 Answers
+ 3
It is explained here: https://docs.python.org/3/tutorial/floatingpoint.html
9th Dec 2022, 11:30 PM
Paul
Paul - avatar
+ 1
It is the same but often you get rounding differences.
9th Dec 2022, 10:50 PM
Paul
Paul - avatar
0
Yes, I obtain a rounding difference and so there is a bug in my code. So, I would like to understand why there is this rounding difference. Thank you for your help :)
9th Dec 2022, 11:22 PM
Roberto Moggia
Roberto Moggia - avatar
0
The tax that is calculated by multiplying the total cost by 1.07, instead of adding 7% to the total cost is a more accurate way of calculating the tax, since it takes into account the fact that the tax is applied to the total cost of the order.
10th Dec 2022, 12:38 AM
CalviŐ˛
CalviŐ˛ - avatar
0
Thank you, for your help! :)
10th Dec 2022, 8:48 AM
Roberto Moggia
Roberto Moggia - avatar
0
How we can write this : x*=0.07 Y=x*7/100
10th Dec 2022, 2:26 PM
Ibtissem Bl
Ibtissem Bl - avatar