In [1]:
f = 123.456
In [2]:
print(round(f))
In [3]:
print(type(round(f)))
In [4]:
print(round(f, 1))
In [5]:
print(round(f, 2))
In [6]:
print(round(f, -1))
In [7]:
print(round(f, -2))
In [8]:
print(round(f, 0))
In [9]:
print(type(round(f, 0)))
In [10]:
i = 99518
In [11]:
print(round(i))
In [12]:
print(round(i, 2))
In [13]:
print(round(i, -1))
In [14]:
print(round(i, -2))
In [15]:
print(round(i, -3))
In [16]:
print('0.4 =>', round(0.4))
print('0.5 =>', round(0.5))
print('0.6 =>', round(0.6))
In [17]:
print('4 =>', round(4, -1))
print('5 =>', round(5, -1))
print('6 =>', round(6, -1))
In [18]:
print('0.5 =>', round(0.5))
print('1.5 =>', round(1.5))
print('2.5 =>', round(2.5))
print('3.5 =>', round(3.5))
print('4.5 =>', round(4.5))
In [19]:
print('0.05 =>', round(0.05, 1))
print('0.15 =>', round(0.15, 1))
print('0.25 =>', round(0.25, 1))
print('0.35 =>', round(0.35, 1))
print('0.45 =>', round(0.45, 1))