Bird
0
0

What will be the output of this procedural Python code?

medium📝 Predict Output Q4 of 15
Python - Object-Oriented Programming Foundations
What will be the output of this procedural Python code?
def add(a, b):
    return a + b

result = add(3, 4)
print(result)
A34
BNone
CTypeError
D7
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function call and return

    The function 'add' takes two numbers and returns their sum.
  2. Step 2: Calculate the result of add(3, 4)

    3 + 4 equals 7, so 'result' stores 7, which is printed.
  3. Final Answer:

    7 -> Option D
  4. Quick Check:

    Function returns sum = 7 [OK]
Quick Trick: Functions return values, print shows them [OK]
Common Mistakes:
  • Thinking '+' concatenates numbers as strings
  • Expecting print to show None if no return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes