id() — Python Technical Interview Questions & Answers
id()
id()
- id() is built into Python. You do not import it. Freshers only need one honest call and the printed result — not a long definition.
- id() — output: True. id is the object identity (memory-ish id).
- Wrong type often raises TypeError. Empty values matter for bool/all/any. Don’t mix id up with a similar name (sorted vs sort, int vs float).
Technical Interview Tip: Call id() once and say what prints.
Code Examples for id()
Example
# id()
a = "Asha"
print(id(a) == id(a))
id() — output: True. id is the object identity (memory-ish id).
How to Explain id() to an Interviewer
Explain id() as if you are teaching a junior — definition, then one tiny script.
id() is built-in — no import. One call + exact output.
What does the example print, and why?
id() — output: True
What mistake do freshers make with id()?
Wrong type → TypeError.