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