Questenaتدريب يوضح لك ما ينبغي مراجعته لاحقًا
السؤال 8

Which result pair is produced by `isinstance(True, int)` and `int(True)`?

  1. `False` and `0`
  2. `False` and `1`
  3. `True` and a TypeError
  4. `True` and `1`الإجابة الصحيحة

الشرح

Python defines `bool` as a subclass of `int`, and the true Boolean value has integer value 1 when converted. The claim that booleans are unrelated to integers overlooks that deliberate numeric relationship.

تابع هذا الاختبار

بدء التدريب
السؤال 8: Which result pair is produced by `isinstance(True, int)`… · Python Fundamentals · Questena