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.

41 Easy Dunder Methods Python

What are dunder methods?

Short take Full answer on next page

Simple meaning

Dunder methods, also called magic methods, are special names with double underscores such as __init__ and __str__.

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

Read full answer Example · Mistake · Say this
42 Easy Dunder Methods Python

What does __str__ do?

Short take Full answer on next page

Simple meaning

__str__ returns the informal string used by str() and print().

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

Read full answer Example · Mistake · Say this
43 Easy Dunder Methods Python

What does __len__ do?

Short take Full answer on next page

Simple meaning

__len__ is called by len() and should return a non-negative int.

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

Read full answer Example · Mistake · Say this
44 Easy Dunder Methods Python

What does __eq__ do?

Short take Full answer on next page

Simple meaning

__eq__ implements == for your class.

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

Read full answer Example · Mistake · Say this
45 Easy Testing Python

What is unittest in Python?

Short take Full answer on next page

Simple meaning

unittest is the standard library's xUnit-style test framework.

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

Read full answer Example · Mistake · Say this
46 Easy Testing Python

What is pytest and why do teams use it?

Short take Full answer on next page

Simple meaning

pytest is a third-party runner with plain assert, fixtures, and rich plugins.

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

Read full answer Example · Mistake · Say this
47 Easy Testing Python

What is Django's TestCase?

Short take Full answer on next page

Simple meaning

django.test.TestCase wraps each test in a database transaction that is rolled back.

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

Read full answer Example · Mistake · Say this
48 Easy Testing Python

Why write tests for Django views?

Short take Full answer on next page

Simple meaning

View tests catch broken URLs, auth, status codes, and template context before production.

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

Read full answer Example · Mistake · Say this
49 Easy Middleware Python

What is Django middleware?

Short take Full answer on next page

Simple meaning

Middleware is a hook that runs on every request and response.

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

Read full answer Example · Mistake · Say this
50 Easy Middleware Python

Where is middleware configured?

Short take Full answer on next page

Simple meaning

The MIDDLEWARE list in settings.py is an ordered sequence of dotted class paths.

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

Read full answer Example · Mistake · Say this
52 Easy Signals Python

What are Django signals?

Short take Full answer on next page

Simple meaning

Signals are a dispatcher that lets decoupled apps react to events such as a model save.

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

Read full answer Example · Mistake · Say this
53 Easy Signals Python

What is post_save used for?

Short take Full answer on next page

Simple meaning

post_save runs after a model is saved to the database.

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

Read full answer Example · Mistake · Say this
54 Easy Signals Python

How do you connect a signal receiver?

Short take Full answer on next page

Simple meaning

Decorate a function with @receiver(post_save, sender=MyModel) or call post_save.connect(handler, sender=MyModel).

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

Read full answer Example · Mistake · Say this
55 Easy DRF Python

What is Django REST Framework?

Short take Full answer on next page

Simple meaning

DRF is a toolkit for building Web APIs on top of Django.

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

Read full answer Example · Mistake · Say this
56 Easy DRF Python

What is a serializer in DRF?

Short take Full answer on next page

Simple meaning

A serializer converts model instances or primitives to JSON-like data and validates incoming payloads.

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

Read full answer Example · Mistake · Say this
57 Easy DRF Python

What is an APIView?

Short take Full answer on next page

Simple meaning

APIView is DRF's base class-based view.

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

Read full answer Example · Mistake · Say this
58 Easy DRF Python

What does the api_view decorator do?

Short take Full answer on next page

Simple meaning

@api_view turns a function into a DRF function-based view and lists allowed methods.

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

Read full answer Example · Mistake · Say this
59 Easy Caching Python

Why cache data in a Django project?

Short take Full answer on next page

Simple meaning

Caching stores expensive query or render results so later requests skip the work.

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

Read full answer Example · Mistake · Say this
60 Easy Caching Python

How do cache.set and cache.get work?

Short take Full answer on next page

Simple meaning

django.core.cache.cache.set(key, value, timeout) stores a pickled value in the configured backend.

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

Read full answer Example · Mistake · Say this
Prev Page 3 of 12 Next
Chat with us