Q: Print numbers in Python I want to save the numbers froms 11 to 15 with the increment of 1 and I have the following code:
import numpy as np
for b in range(11,15,1):
    np.savetxt('tmp.txt',np.c_[b],fmt='%1.3f')

But I am able to save only one number that is 14. Help me for this.

A: You are replacing the file 'tmp.txt' in each iteration of the loop.
Instead, you can open a file in append mode and then write to it using the same function:
import numpy as np
f=open('tmp.txt','ab')
for b in range(11,15,1):
    np.savetxt(f,np.c_[b],fmt='%1.3f')
f.close()


A: I assume you want to have one number per line. This would work:
import numpy as np
np.savetxt('tmp.txt', np.arange(11,16,1), fmt='%1.3f')

@Ni is right, your solution doesn't work, because "you are replacing the file 'tmp.txt' in each iteration of the loop".
Numpy's savetxt method takes an array and saves it to a file. Each element on a separate line (by default). No need for iterations. See the docs.
Regarding the range method. Numpy's arange method generates values within the half-open interval [11, 15) in your case. That should explain why you need to insert 16 instead of 15. Again have a look at the docs.
