Being a linear sequence generator, the numpy.arange()
function is used to generate a sequence of numbers in linear space with a uniform step size.
作为线性序列生成器, numpy.arange()
函数用于在线性空间中以均匀步长生成数字序列。
This is similar to another function, numpy.linspace(), which also generates a linear sequence with a uniform step size.
这类似于另一个函数numpy.linspace() ,该函数还生成具有均匀步长的线性序列。
Let’s understand how we can use this function to generate different sequences.
让我们了解如何使用此函数生成不同的序列。
句法 (Syntax)
Format:
格式:
array = numpy.arange(start, stop, step, dtype=None)
Here,
这里,
start
-> The starting point (included) of the range, which is set to 0 by default.start
>范围的起点( 包括在内 ),默认情况下设置为0 。stop
-> The ending point (excluded) of the rangestop
->范围的终点( 不包括 )step
-> The step size of the sequence, which is set to 1 by default. This can be any real number except Zero.step
>序列的步长,默认设置为1。 除零外,它可以是任何实数。dtype
-> The type of the output array. Ifdtype
is not given (or provided asNone
), the datatype will be inferred from the type of other input arguments.dtype
>输出数组的类型。 如果未给出dtype
(或作为None
提供),则将从其他输入参数的类型推断出数据类型。
Let us take a simple example to understand this:
让我们举一个简单的例子来理解这一点: