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

What happens when Python evaluates `1 < "2"`?

  1. `True` after converting the string to an integer
  2. `False` because all strings sort before integers
  3. A `TypeError` because Python does not auto-convert themالإجابة الصحيحة
  4. A stable result based on the objects' memory locations

الشرح

An integer and a string are unrelated built-in types for ordering, so Python raises `TypeError`. It does not parse the string as a number or impose a universal cross-type sort order.

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

بدء التدريب
السؤال 60: What happens when Python evaluates `1 < "2"`? · Python Fundamentals · Questena