1. Home
  2. Data Science
  3. Python
  4. What is the output of the following Python code snippet?

Added 25 Nov 2026

What is the output of the following Python code snippet?

a = 256; b = 256
x = [1]; y = [1]
print(a is b, x is y)
  1. True False Correct answer
  2. True True
  3. False False
  4. False True

Correct answer

A. True False

MCQSEXAM

Explanation

Small integers are cached by CPython so a is b is True, but two separately built lists are different objects.

Reference

Asked in: Python Interview Data Types

https://docs.python.org/3/library/stdtypes.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs