Answers for "np.arange and np.linspace difference"

0

np.arange and np.linspace difference

# np.arrange allows you to define the stepsize 

>>> np.arange(0,1,0.1) #--> 0.1  is the stepsize or interval 
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])

# np.linspace allows you to define how many values you get including the specified min and max value

>>> np.linspace(0,1,11) #--> 11  no of values you need
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])
Posted by: Guest on September-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language