Variables, Types & Operators · Question 12 · Medium

Two separate lists hold the same values and a third name points to the first list. What is printed?

a = [1, 2]
b = [1, 2]
c = a
print(a == b, a is b, a is c)
  1. True True True
  2. False False True
  3. True False True
  4. True False False
Answer and explanation

Answer: C. True False True

Explanation: == compares contents, and both lists hold 1 and 2, so a == b is True. is checks whether two names refer to the same object: a and b are two different lists (False), while c was assigned from a and is the same list (True).

Previous: A voter-age check uses chained comparisons. What does it print for age 21? · Next: Python 3's round() is called on two values that end in .5. What does this 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