can you help me with array

Question:

I have a problem how to do array starting from 1,1/2,1/3,1/4,1/5,……,1/99,1/100 in Python

Asked By: Samir

||

Answers:

You are probably looking for np.put:

a = np.zeros(100)
for i in range(100):
    a.put(i, 1/(i+1))

Edit:
After changing the original question, the best answer now is:

a = 1.0 / np.linspace(1, 100, 100)
Answered By: bitflip
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.