Bird
0
0

What will be the output type of the following code?

medium📝 Predict Output Q4 of 15
SciPy - Statistical Functions (scipy.stats) Basics
What will be the output type of the following code?
from scipy.stats import poisson
samples = poisson.rvs(mu=3, size=5)
print(type(samples))
A<class 'list'>
B<class 'numpy.ndarray'>
C<class 'int'>
D<class 'float'>
Step-by-Step Solution
Solution:
  1. Step 1: Understand output of rvs with size parameter

    When size is specified, rvs() returns a NumPy array of samples.
  2. Step 2: Check the printed type

    Printing type(samples) will show <class 'numpy.ndarray'>.
  3. Final Answer:

    <class 'numpy.ndarray'> -> Option B
  4. Quick Check:

    rvs(size=) returns numpy.ndarray [OK]
Quick Trick: rvs with size returns numpy array, not list [OK]
Common Mistakes:
MISTAKES
  • Assuming list instead of ndarray
  • Expecting single int when size>1
  • Confusing float with int type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes