Computer Science · Python Basics
Consider the following Python code segment: a = 10; b = 10; print(a is b). It prints 'True'. What is the reason behind this behavior?
- 1Integers cannot share memory in Python under any circumstances
- 2The code contains a syntax error because semicolons are not allowed
- 3The 'is' operator compares values, not memory identities
- 4Both variables reference the same memory object due to integer caching for small integers✓
Correct answer
Both variables reference the same memory object due to integer caching for small integers
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Python Basics?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Python Basics