0
How to round a number in python
Eg:4/3=0 and not 0. 66666.....
10 Antworten
+ 5
if you want to round it accurately: round(4/3,(number of decimal places))
returns 1
if you want to round down: math.floor(4/3)
returns 1
if you want to round up: math.ceil(4/3)
returns 2
Note that you'll have to import math for the last two examples to work.
+ 2
round(4/3, -1)
round(4/3, 2) would round with 0.01 accuracy: 1.33
round(4/3, -2) would run with 100 accuracy: 0.0
+ 1
Avinesh By rounding to 10s or higher.
+ 1
Thx guy hope you live a long and happy life
+ 1
Jannik Müller 4/3 ~ 1.33333
+ 1
Seb TheS I know. That's what happens when I do multiple things at once... Mistakes are corrected
0
How would 4/3 will give 0. something?
Hope this works too-
x=int(4/3)
print(x)
0
Use //
0
Wat