1. Home
  2. Data Science
  3. NumPy
  4. What does the np.linspace() function do in NumPy?

Added 24 Feb 2024

What does the np.linspace() function do in NumPy?

  1. Generates an array of equally spaced numbers over a specified interval Correct answer
  2. Generates an array of random numbers from a uniform distribution
  3. Generates an array of random numbers from a normal distribution
  4. Generates an array of random integers

Correct answer

A. Generates an array of equally spaced numbers over a specified interval

14 views

MCQSEXAM

Explanation

np.linspace() generates equally spaced numbers over a specified interval: np.linspace(0, 1, 5) gives [0, 0.25, 0.5, 0.75, 1]. The endpoint is included by default.

Unlike arange(), you specify how many points you want, not the step size.

Want more practice? Try the full set of Data Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More NumPy MCQs

Practise all NumPy MCQs

Similar MCQs