numpy.linspace()

It is similar to the arrange function. However, it doesn?t allow us to specify the step size in the syntax.

Instead of that, it only returns evenly separated values over a specified period. The system implicitly calculates the step size.

Syntax

Parameters

It accepts the following parameters.

  1. start: It represents the starting value of the interval.
  2. stop:It represents the stopping value of the interval.
  3. num: The amount of evenly spaced samples over the interval to be generated. The default is 50.
  4. endpoint: Its true value indicates that the stopping value is included in the interval.
  5. rettstep: This has to be a boolean value. Represents the steps and samples between the consecutive numbers.
  6. dtype: It represents the data type of the array items.

Return

An array within the specified range is returned.

Example 1

Output:

The array over the given range is  [10.  12.5 15.  17.5 20.]

Example 2

Output:

The array over the given range is  [10. 12. 14. 16. 18.]





Latest Courses