range() and arange() Functions can be used to generate equal interval ( Isochromatic ) Sequence , Can be used to iterate .
Both function prototypes have three parameters :
range([start,] stop, [step])
arange([start,] stop, [step])
linspace(start, stop, num, endpoint=True, retstep=False, dtype=None)
start: Optional parameters , Indicates the starting value , The default is 0, The result contains the starting value
stop: Required parameters , Indicates the end value , The result does not contain an end value
step: Optional parameters , Represents the step value , The default is 1
range() yes python The built-in function of ;
arange() yes numpy Functions in modules , When using, you need to import numpy modular .
range() Decimal step size is not supported , and np.arange() Support step size step Is a decimal
range() The return result of is list object
arange() The return result of is ndarray object .
inspace() By specifying the starting value 、 The final value and the number of elements create a one-dimensional array representing an arithmetic sequence , Can pass endpoint Parameter specifies whether to include a final value , The default value is True, namely Include final value .
range and numpy.arange It's all based on the starting value 、 Termination value 、 The step size is a parameter , and linspase With the starting value 、 Termination value 、 The number of elements is a parameter .