The Python version also affects the results, and python2 the x round to the nearest multiple from 0, such as round (0.5) =1, round (-0.5) =-1;
Python3 rounds x to the nearest number of even multiples, such as round (0.5) =0, round (1.5) =2.0, round (2.5) = 2.0, and the following are the output of the python2.7
1. Direct Output
Division: An integer that is divisible by a decimal point.
Print 6/2
print 6/2.0
print 6/2.00
print 6/2.000
print 6.0/2
print 6.00/2
print 6.000/2
Results:
3
3.0
3.0
3.0
3.0
3.0
3.0
Non-division: Real Results
Print 6.1/2 print
6.10/2 print
6.100/2
print 6.11/2
2. Precision Control
High precision---Low precision round ()
Round ()-do not specify, rounding, rounded (if encountered. 5 accidentally discard Odd)
Print round (2.3) Print
round (2.6) Print
round (2.5)
print round (1.5)
Round ()--Specify the number of decimal places, rounded (if encountered. 5 on the contrary, I enter a singular discard)
Print round (2.635, 2) Print
round (2.645, 2) print round
(2.655, 2) print round (
2.665, 2)
print round ( 2.675, 2)
Formatting
Print ("%.2f"% 2.635)
print int (2.635)