python modulus and / division Notes

The python is modulo rounding down method, and the c / c ++ / java based on the rounding of the.

python3 in:

 / Division is accurate, it is rounded down to the divisible // method;

print('123 / 10 = ', 123 / 10)
print('123 // 10 = ', 123 // 10)

 

 

For negative There need to pay attention:

Python3 in

In the language c, divided by 10 = -53 -5 

 

% Is the modulo of rounding to whole round, int rounding to zero, rounding up and down function math.floor, math.ceil

 

Published 83 original articles · won praise 14 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_38121168/article/details/103323418