Variables, Types & Operators · Question 15 · Medium

Which statement about the operators == and is is correct?

  1. == compares the values of two objects, while is checks whether both names refer to the same object
  2. is compares the values of two objects, while == checks whether both names refer to the same object
  3. Both give the same result for any two lists that have equal contents
  4. is can be used only with numbers, while == works with every type
Answer and explanation

Answer: A. == compares the values of two objects, while is checks whether both names refer to the same object

Explanation: == asks whether two objects are equal in value; is asks whether they are one and the same object in memory. Two separately built lists with equal contents are == but not is.

Previous: A string holding a decimal number is passed straight to int(). What is the… · Next: Booleans are used in arithmetic here. What does the snippet print?

Practise variables, types & operators

Try a fresh set of variables, types & operators questions with an explanation after every answer, free and without signing up: Variables, Types & Operators practice. Or sit a full placement mock test.

More variables, types & operators questions

More python practice

Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge