Python number rounding depends on the number
In python, I am using rounding to 1 decimal. But If a number is 0.03 or 0.005, then It should show until the last number in the decimal places.
def calculate_total(number):
# some number calcualtions
number = round(number, 1)
print(number)
calculate_total(66.36) # 66.4
calculate_total(3.34) # 3.3
calculate_total(3.34) # 3.3
calculate_total(0.03) # 0.0 (But it should show 0.03)
calculate_total(0.0364) # 0.0 (But it should show 0.04)
That is because you are rounding the float to one decimal place in z = 0.03
and z = 0.0364
Just change print(round(z, 1))
to print(round(z, 2))
; this will change the decimal place from 1 to 2 and it will produce your required output.