Bird
0
0

Why does this code cause an error?

medium📝 Debug Q7 of 15
Python - Methods and Behavior Definition
Why does this code cause an error?
def add(x, y):
    return x + y

print(add(3))
AReturn statement is incorrect
BMissing one argument in function call
CFunction name is invalid
Dprint cannot call functions
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameters and call

    Function add requires two arguments, but only one is given.
  2. Step 2: Understand error cause

    Python raises a TypeError because of missing argument.
  3. Final Answer:

    Missing one argument in function call -> Option B
  4. Quick Check:

    Function call must match parameters [OK]
Quick Trick: Match function call arguments to parameters [OK]
Common Mistakes:
  • Calling function with fewer arguments
  • Misreading error as return problem
  • Thinking print cannot call functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes