Bird
0
0

What is the output of this code?

medium📝 Predict Output Q13 of 15
SciPy - Basics and Scientific Computing
What is the output of this code?
import numpy as np
from scipy import special
x = np.array([0, 1, 2])
y = special.expit(x)
print(y)
A[0.5 0.73105858 0.88079708]
B[1. 2. 7.3890561]
C[0. 1. 2.]
D[0. 0.5 0.75]
Step-by-Step Solution
Solution:
  1. Step 1: Understand special.expit function

    special.expit computes sigmoid 1 / (1 + exp(-x)): sigmoid(0)=0.5, sigmoid(1)≈0.73105858, sigmoid(2)≈0.88079708 matching [0.5 0.73105858 0.88079708].
  2. Final Answer:

    [0.5 0.73105858 0.88079708] -> Option A
  3. Quick Check:

    sigmoid([0,1,2]) = [0.5 0.73105858 0.88079708] [OK]
Quick Trick: expit = sigmoid function, check values at 0,1,2 [OK]
Common Mistakes:
MISTAKES
  • Confusing expit with exponential
  • Expecting raw input array as output
  • Mixing up output with other functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes