k.dav
k.dav

Reputation: 59

Creating an array of a specified length

If I have a minimum value for an array,

 min = 50

and a max value:

  max = 60

How do I create an array that starts at 50, ends at 60, and has a total of 6 values in the list? Something like the following, that could also handle creating decimal values instead of integers.

array = [50, 52, 54, 56, 58, 60]

Upvotes: 0

Views: 185

Answers (1)

tstanisl
tstanisl

Reputation: 14107

Try:

np.linspace(50, 60, num=6, endpoint=True, dtype=int)
array([50, 52, 54, 56, 58, 60])

Upvotes: 2

Related Questions