QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 7

Suppose class `child` inherits from class `parent`, and `item` is a `child` instance. What does `isinstance(item, parent)` return?

  1. It raises TypeError because the classes differ.
  2. It returns false because only exact instances match.
  3. It returns true because subclasses are included.Ճիշտ պատասխան
  4. It compares the textual class names and returns false.

Բացատրություն

The check accepts instances of the named class and of its subclasses, so a `child` instance satisfies a test against `parent`. Requiring an exact class match would describe a direct `type` comparison, not `isinstance`.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 7: Suppose class `child` inherits from class `parent`, and… · Python Fundamentals · Questena