Dec-15-2021, 01:53 PM
Hi,
I'd like to round the number 12.13 to 12 and 12.45 to 13.
None of the following functions return the format I'm looking for. I guess I could use if then function to get around it but, I'm sure there's an easy way to solve this.
TIA
I'd like to round the number 12.13 to 12 and 12.45 to 13.
None of the following functions return the format I'm looking for. I guess I could use if then function to get around it but, I'm sure there's an easy way to solve this.
TIA
import math a = 12.13 b = 12.45 print(round(a), round(b)) # incorrect print(math.ceil(a), math.ceil(b)) # incorrect print(math.floor(a), math.floor(b)) # incorrect print(math.trunc(a), math.trunc(b)) # incorrect