range

  1. The characteristics of

    Range () is a built-in Python function that specifies a start value, an end value, and a step to generate a one-dimensional array of arithmetic sequences

  • No final value is included
  • The step size must be an integer, generating an integer type
  • The range object is returned
  1. The test code
a = range(1.10.1)
print(a)
b = range(1.10.3)
print(b)
c = range(1.10.0.5)
print(c)
Copy the code
  1. The results
  • A and B successfully generated range objects

  • C an error

np.arange

  1. The characteristics of

    Np.arange () is used similarly to range(), specifying the start value, end value, and step size to generate a one-dimensional array of arithmetic sequences

  • No final value is included
  • The step size does not have to be an integer and can generate a floating-point type
  • Returns an array array
  1. The test code
a = np.arange(1.5.1)
b = np.arange(1.5.0.5)
print(a)
print(b)
Copy the code
  1. The results

np.linspace

  1. The characteristics of

    Np.linspace () generates a one-dimensional array of arithmetic sequences by specifying the start value, end value, and number of elements

  • The final value is included by default and can be specified by setting the value of the endpoint parameter

  • The step size does not have to be an integer and can generate a floating-point type

  • Returns an array array

  1. The test code
a = np.linspace(1.10.10)
print(a)
b = np.linspace(1.10.9)
print(b)
c = np.linspace(1.10.9,endpoint=False)
print(c)
Copy the code
  1. The results