a = 1
for x in range(5):
a += 0.1
print(a)
This is the result:
1.1
1.2000000000000002
1.3000000000000003
1.4000000000000004
1.
Formatted output has been duly suggested by @Jaco. However, if you want control of precision in your variable beyond pure output, you might want to look at the decimal module.
from decimal import Decimal
a = 1
for x in range(3):
a += Decimal('0.10') # use string, not float as argument
# a += Decimal('0.1000')
print(a) # a is now a Decimal, not a float
> 1.10 # 1.1000
> 1.20 # 1.2000
> 1.30 # 1.3000