1. Home
  2. Data Science
  3. NumPy
  4. What is the output of np.random.randint(1, 10, size=(2, 3))?

Added 24 Feb 2024

What is the output of np.random.randint(1, 10, size=(2, 3))?

  1. A 2x3 array with random integers between 1 and 10 Correct answer
  2. An array of random floats between 1 and 10
  3. A single random integer between 1 and 10
  4. An error

Correct answer

A. A 2x3 array with random integers between 1 and 10

15 views

MCQSEXAM

Explanation

It returns a 2×3 array of random integers from 1 up to, but not including, 10. In randint(low, high, size) the upper bound is exclusive, so the values lie between 1 and 9.

The size argument sets the shape of the output.

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