I wrote a very simple code in Python.
I need to print all the numbers between 1
and 5
(including 1
and 5
) in steps of 0.1
. The integers should be without the suffix .0
, i.e. the output should be:
0
0.1
0.2
...
1
1.1
...
...
5
Here is my code:
for i in range(0,51):
if i%10==0:
z=int(i/10)
print (z)
else:
print (i*0.1)
Here is my output:
0
0.1
0.2
0.30000000000000004
0.4
0.5
0.6000000000000001
0.7000000000000001
0.8
0.9
1
1.1
1.2000000000000002
1.3
1.4000000000000001
1.5
1.6
1.7000000000000002
1.8
1.9000000000000001
2
2.1
2.2
2.3000000000000003
2.4000000000000004
2.5
2.6
2.7
2.8000000000000003
2.9000000000000004
3
3.1
3.2
3.3000000000000003
3.4000000000000004
3.5
3.6
3.7
3.8000000000000003
3.9000000000000004
4
4.1000000000000005
4.2
4.3
4.4
4.5
4.6000000000000005
4.7
4.800000000000001
4.9
5
I don't need all this zeros .000000001
.