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

Added 24 Feb 2024

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

  1. Seeds the random number generator for reproducibility Correct answer
  2. Generates a random seed value
  3. Sets the state of the random number generator
  4. Resets the random number generator

Correct answer

A. Seeds the random number generator for reproducibility

16 views

MCQSEXAM

Explanation

np.random.seed() seeds the random number generator for reproducibility. Using the same seed produces the same "random" numbers on every run, which is essential for debugging and for repeatable experiments.

Newer code often uses np.random.default_rng(seed) instead.

Keep preparing with more 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