In python, round (x, [n]) uses round (x, [n]) to rounding n to retain the number of fractional parts
1. when n is not entered, the default value is 0, that is, the fractional part is not retained.
A. When the decimal part is only 0.5, if the integer part is an odd number, 1 is entered. if the decimal part is an even number, the decimal part is removed.
Print (round (1.5) #2 if the decimal part is 0.5 and the integer part is odd, then + 1
Print (round (2.5) #2. if the decimal part is 0.5 and the integer part is an even number, the decimal part is removed.
Print (round (-1.5) #-2
Print (round (-2.5) #-2
Print (round (1.4) #1
Print (round (2.4) #2
Print (round (-1.4) #-1
Print (round (-2.4) #-2
B. If the decimal part is not 0.5, rounding
Print (round (1.54) #2 decimal places 0.54 in 1
Print (round (2.54) #3
Print (round (-1.54) #-2
Print (round (-2.54) #-3
Print (round (1.45) #1 decimal number 0.45
Print (round (2.45) #2
Print (round (-1.45) #-1
Print (round (-2.45) #-2
2. when the fractional part is retained
A. When the last digit of the decimal part is 5, when the number of reserved locations is an even number, 1 and an odd number are removed.
Print (round (2.635, 2) # The last digit of the 2.63 retention number is 5, and the reserved position is 3, which is an odd number.
Print (round (2.645, 2) # if the last digit of 2.65 is 5 and the position of 4 is an even number, enter 1
Print (round (2.655, 2) #2.65
Print (round (2.665, 2) #2.67
Print (round (2.675, 2) #2.67
B. When the last digit is not 5, rounding
Print (round (2.636, 2) #2.64
Print (round (2.646, 2) #2.65
Print (round (2.656, 2) #2.66
Print (round (2.666, 2) #2.67
Print (round (2.676, 2) #2.68