31 July 2020
Code
# Import library
import numpy as np
# Create array - 1
x1 = np.linspace(start = 1, stop = 10, num = 10)
# Create array - 2
x2 = np.arange(start = 1, stop = 10, step = 1)
# Output
print("Using 'linspace': \n", x1)
print("Type:", type(x1))
print("dtype: ", x1.dtype)
print('\n', "Using 'arange': \n", x2)
print("Type:", type(x2))
print("dtype: ", x2.dtype)
Output
Using 'linspace':
[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
Type: <class 'numpy.ndarray'>
dtype: float64
Using 'arange':
[1 2 3 4 5 6 7 8 9]
Type: <class 'numpy.ndarray'>
dtype: int64
Any errors in code above?
Please send a message.