Bird
0
0

Given a file math_ops.py with this code:

medium📝 Predict Output Q13 of 15
Python - Modules and Code Organization
Given a file math_ops.py with this code:
def add(a, b):
    return a + b

What will be the output of this code?
import math_ops
print(math_ops.add(3, 4))
A7
B34
CTypeError
DNameError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function in math_ops.py

    The function add takes two numbers and returns their sum.
  2. Step 2: Analyze the import and function call

    Importing math_ops allows calling math_ops.add(3, 4), which returns 3 + 4 = 7.
  3. Final Answer:

    7 -> Option A
  4. Quick Check:

    3 + 4 = 7 [OK]
Quick Trick: Imported functions run normally with correct arguments [OK]
Common Mistakes:
  • Confusing string concatenation with addition
  • Expecting errors due to import
  • Forgetting to call function with parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes