7

How can I create a numpy array which has values in a specific range. For instance only from 2 to 10! I know that np.arrange(10) will create an array with 10 values from 0 to 9 but not sure how to indicate that I want it to have values in a specific range. Any idea? Thanks in advance

3

2 Answers 2

6

As others and the documentation says

np.arange(2,11)

Here is a working example https://repl.it/@Sudakatux/simplenumpy

Here are the docs: https://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html

Sign up to request clarification or add additional context in comments.

Comments

0

It should be like:

import numpy as np
x = np.arange(2,11)
print(x)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.