Bird
Raised Fist0

What will be the output of this code?

medium📝 Predict Output Q4 of Q15
Python - Modules and Code Organization
What will be the output of this code?
from math import factorial
print(factorial(5))
A24
B120
C5
DError: factorial not defined
Step-by-Step Solution
Solution:
  1. Step 1: Understand what factorial(5) computes

    Factorial of 5 is 5 x 4 x 3 x 2 x 1 = 120.
  2. Step 2: Confirm import allows calling factorial directly

    Importing factorial specifically allows calling it as factorial(5).
  3. Final Answer:

    120 -> Option B
  4. Quick Check:

    factorial(5) = 120 [OK]
Quick Trick: Import specific function to call it directly without module prefix [OK]
Common Mistakes:
MISTAKES
  • Confusing factorial(5) with factorial(4)
  • Expecting error due to wrong import
  • Thinking factorial returns 5 instead of product

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes