day1/exercise/round_float.py
changeset 69 9fbd2a71fef2
parent 64 333092b68926
equal deleted inserted replaced
68:0471f8694075 69:9fbd2a71fef2
       
     1 # round using int
       
     2 n = 17.3 # any float
       
     3 int (n + .5)
       
     4 
       
     5 # round it off to first decimal place
       
     6 round(amount * 10) / 10.0
       
     7 
       
     8 # round it off to nearest 5 paise
       
     9 round(amount * 20) / 20.0
       
    10 
       
    11 # exchange two variables
       
    12 a, b = b, a