summaryrefslogtreecommitdiff
path: root/day1/exercise/round_float.py
blob: 7c1b74521f97dd8822b628c78af9be5656d48c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# round using int
n = 17.3 # any float
int (n + .5)

# round it off to first decimal place
round(amount * 10) / 10.0

# round it off to nearest 5 paise
round(amount * 20) / 20.0

# exchange two variables
a, b = b, a