Daily Data Science Puzzle
import numpy as np year = np.linspace(0, 365, 366) print(int(year[-1] - year[-2]))
What is the output of this puzzle?
Numpy is a popular Python library for data science focusing on linear algebra.
This puzzle is about the useful function linspace. In particular,
linspace(start, stop, num) returns evenly spaced numbers over a given interval
[start, stop], with stop included.
linspace(0,3,4) returns the numpy array sequence 0,1,2,3 (i.e., 4 evenly spaced numbers).
This function is particularly useful when plotting (or evaluating) a function. The result of the function applied to evenly spaced numbers reveals how it progresses for growing parameter values.
Are you a master coder?
Test your skills now!