Bird
0
0

Find the error in this multiple inheritance code:

medium📝 Debug Q14 of 15
Python - Multiple Inheritance and Method Resolution
Find the error in this multiple inheritance code:
class X:
    pass

class Y:
    pass

class Z(X Y):
    pass
AMissing colon after class name
BMissing comma between parent classes
CParent classes must be in square brackets
DClass Z cannot inherit from X and Y
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for multiple inheritance

    Parent classes must be separated by commas inside parentheses.
  2. Step 2: Identify the syntax error

    In class Z(X Y):, the comma between X and Y is missing, causing a syntax error.
  3. Final Answer:

    Missing comma between parent classes -> Option B
  4. Quick Check:

    Comma missing between parents = SyntaxError [OK]
Quick Trick: Separate parent classes with commas inside parentheses [OK]
Common Mistakes:
  • Forgetting commas between parent classes
  • Using square brackets instead of parentheses
  • Thinking multiple inheritance is not allowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes