nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
Questions
7 of 12
1What is an Interpreted language?
2Is Python a compiled language or an interpreted language?
3What is the difference between `/` and `//` in Python?
4Why can `a = 256; b = 256; a is b` return `True`, but `a = 257; b = 257; a is b` return `False` in some Python implementations?
5What is the difference between a shallow copy and a deep copy? When would each cause bugs?
6What causes a reference cycle, and how does Python's garbage collector handle it?
7What is the difference between `is` and `==`?
8How does Python evaluate chained comparisons like `1 < x < 10`?
9What are Python's built-in data types, and how are they categorized (mutable vs. immutable)?
10How does Python manage memory for objects internally (reference counting and the object model)?
11Why does Python not require explicit variable declarations, and how does dynamic typing affect variable assignment internally?
12Why can floating-point arithmetic in Python produce results like `0.1 + 0.2 != 0.3`? How would you correctly compare floats?
PythonPython
Basics
Control Flow and Functions
Data Structures
Comprehensions & Functional Programming
Iterators, Generators & Decorators
Object-Oriented Programming
Exception Handling & Debugging
Concurrency & Parallelism
Performance & Optimization
Testing
Security
Modules, Packaging & Environment
Type Hinting & Modern Python
System Design & Architecture with Python
Best Practices & Design Patterns
Edge Cases & Tricky Interview Questions
07 / 12
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Mock Interviews
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

What is the difference between `is` and `==`?

Difficulty: 3/10
Variables, Data Types & Memory Model, Identity vs Equality, Singletons and Sentinels

Identity versus equality

== is value equality: it calls type(a).eq(a, b) (with reflection and NotImplemented fallback rules), so the class decides what 'equal' means. is is identity: it checks whether both operands are the very same object, which in CPython means comparing addresses, and it cannot be overridden. Equal objects are not necessarily identical, but identical objects are almost always equal (NaN is the famous exception).

javascript

When I use each: is for singletons (None, True, False, Ellipsis) and sentinels, == for everything else. 'is None' is preferred because it is faster, expresses intent, and cannot be fooled by a custom eq; with numpy or pandas, x == None produces an element-wise array (or an ambiguous-truth-value error) while x is None answers the question you meant.

Common mistakes: using is to compare strings or numbers (it works by accident for small ints and interned strings in CPython, then fails elsewhere - Python 3.8+ emits a SyntaxWarning for is with a literal), and forgetting that collections shortcut with identity first, which is why a list containing NaN can compare equal to itself. Also remember that if you define eq without hash, instances become unhashable; equality and hashing must stay consistent.

Scenario Questions

0-2 years experience

  1. 1A function checks if result is [] to detect an empty list and the branch never runs. Why, and how should you write it?
  2. 2Why is 'is None' preferred over '== None'? Give an example where they give different answers.

2-5 years experience

  1. 1A test shows assert x == x failing for a float but [x] == [x] passing. Explain what is going on.
  2. 2You need to tell 'argument not provided' apart from 'argument explicitly set to None'. How do you implement this with is?

5-8 years experience

  1. 1A class defines __eq__ and instances behave erratically in sets and dict keys. What is missing, and how are identity, equality and hash related?
  2. 2A numpy user writes if arr == None: and gets odd results. Explain exactly what happens and how 'is None' avoids it.

8+ years experience

  1. 1You are building an interning/flyweight cache for millions of objects. When can you safely use is for fast equality, and what invariants must you enforce?
  2. 2Design __eq__ for a Base/Derived class hierarchy so it stays symmetric and transitive. When should it return NotImplemented, and what bugs appear if you get it wrong?

Follow-up Questions

  • Why does a class that defines __eq__ become unhashable, and how do you fix it?
  • Why is 'x is None' considered more reliable than 'x == None'?
Sharethis question

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.