Guide Python Intermediate

5.17 Interview Questions

Frequently asked and scenario-based Python data type interview questions covering list vs tuple, bool as an int subclass, mutable defaults, and JSON type mapping.

2 min read

Frequently Asked Questions

  • What is the difference between a list and a tuple?
  • Why is bool considered a subclass of int?
  • What’s the difference between == and is?
  • Why can’t a list be used as a dictionary key, but a tuple can?
  • What is the mutable default argument bug, and how do you fix it?
  • What is the difference between type() and isinstance()?

Scenario-Based Questions

  • You need to store a million IP addresses and check membership repeatedly and fast — which type do you choose, and why?
  • A function silently accumulates data across unrelated calls — what bug pattern should you suspect first?
  • Given a parsed JSON API response, what Python types will the JSON object, array, string, number, true/false, and null become?
  • Why might 0.1 + 0.2 == 0.3 evaluate to False, and how would you compare floats safely instead?

Quick Interview Answer

“The data-type questions that come up most are: list vs tuple (mutability, hashability), why bool is a subclass of int, == vs is (value vs identity), why only hashable/immutable types work as dict keys, and the mutable default argument bug. Scenario questions usually test whether you’d reach for a set for fast membership checks, and whether you know JSON’s true/false/null map to bool/None in Python.”

Common Mistakes

  • Answering “list and tuple are basically the same” without mentioning the mutability difference and its downstream consequences (hashability, dict-key eligibility).
  • Not being able to explain why the mutable default argument bug happens (default values are evaluated once, at function definition time), only that it’s “a gotcha.”

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form