R

Ram Sharma • 3.40K Points
Extraordinary

Q. How do you check if an object belongs to a class?

  • (A) object instanceof class
  • (B) type(object) == class
  • (C) isinstance(object, class)
  • (D) object.type == class
  • Correct Answer - Option(C)
  • Views: 2
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
`isinstance(obj, Class)` checks if `obj` is an instance of `Class` or its subclass.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.