day1/exercise/round_float.py
changeset 64 333092b68926
equal deleted inserted replaced
63:f5eac04a00fe 64:333092b68926
       
     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