I have a number 120 and I divided by 100. I am getting 1.2 but actually I want to get 2 only (not 2.0) in python without importing any lib.
Can any one help here???
I have a number 120 and I divided by 100. I am getting 1.2 but actually I want to get 2 only (not 2.0) in python without importing any lib.
Can any one help here???
You can use the modulo operator to know whether to round up the result:
120//100 + (1 if 120%100 else 0)
You can use the built-in function ceil() to round 1.2 up to 2, and the built-in int function to cast it to an integer:
In [3]: int(ceil(120/100.0))
Out[3]: 2