Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 52

Spot the accurate distinction between `a == b` and `a is b` in Python comparisons.

  1. Both operators always perform the same test.
  2. Identity converts both operands before comparing values.
  3. Equality compares values; identity tests whether the object is the same.پاسخ درست
  4. Equality checks memory location; identity compares converted values.

توضیح

Equality delegates to value-comparison semantics, whereas identity asks whether both references designate one object. Treating `is` as a stricter value conversion obscures that it answers a different question rather than applying a stronger equality rule.

ادامهٔ این آزمون

شروع تمرین