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.

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

Սկսել վարժանքը
Հարց 52: Spot the accurate distinction between `a == b` and `a is b`… · Python Fundamentals · Questena