Bird
Raised Fist0

If you have a custom module calculator.py with:

medium📝 Predict Output Q5 of Q15
Python - Modules and Code Organization
If you have a custom module calculator.py with:
def multiply(x, y):
    return x * y

What will this code print?
from calculator import multiply
print(multiply(3, 4))
A12
Bmultiply
C3 * 4
DError: module not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand import statement

    Using 'from calculator import multiply' imports the multiply function directly.
  2. Step 2: Evaluate the function call multiply(3, 4)

    It returns 3 times 4, which is 12.
  3. Final Answer:

    12 -> Option A
  4. Quick Check:

    Direct import function call = 12 [OK]
Quick Trick: Use 'from module import func' to call func directly [OK]
Common Mistakes:
MISTAKES
  • Expecting function name printed instead of result
  • Confusing import syntax causing errors
  • Assuming module not found without correct file

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes