Python track

Python interview questions and answers

Panel-ready Python & Django questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.

4 Moderate Data Types Python

What goes wrong with a mutable default argument?

Short take Full answer on next page

Simple meaning

The default object is created once, at function definition, and shared across calls.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
6 Moderate GIL Python

When do threads still help in CPython despite the GIL?

Short take Full answer on next page

Simple meaning

Threads help when they spend time in I/O or in C code that releases the GIL, such as reading sockets, waiting on a database driver, or compressing in zlib.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
9 Moderate Decorators Python

How do you write a decorator that accepts arguments?

Short take Full answer on next page

Simple meaning

Use a nested factory: the outer function takes decorator arguments and returns the real decorator, which returns the wrapper.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
10 Moderate Decorators Python

How can a class act as a decorator?

Short take Full answer on next page

Simple meaning

If a class implements __init__ to receive the function and __call__ to run the wrapper, instances are callable decorators.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
14 Moderate Generators Python

What does generator.send() do?

Short take Full answer on next page

Simple meaning

send(value) resumes the generator and makes yield return that value inside the function.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
16 Moderate Generators Python

What is yield from used for?

Short take Full answer on next page

Simple meaning

yield from subgen delegates iteration to another iterable or generator, forwarding values, send, and throw.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
17 Moderate OOP Python

What is the method resolution order (MRO)?

Short take Full answer on next page

Simple meaning

MRO is the linear order Python uses to find attributes on a class and its bases.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
19 Moderate OOP Python

What are abstract base classes in Python?

Short take Full answer on next page

Simple meaning

ABCs, from abc.ABC, let you declare abstract methods that subclasses must implement.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
20 Moderate OOP Python

How does a property differ from a plain attribute?

Short take Full answer on next page

Simple meaning

@property turns a method into managed attribute access so callers use obj.x instead of obj.x().

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
Page 1 of 5 Next
Chat with us