Django / FastAPI Interview Questions Hindi mein

Django / FastAPI कोर्स के 26 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

Python Web Frameworks

1. Which framework includes an admin site and ORM by default?

  1. Neither
  2. FastAPI
  3. Django
  4. Both equally
जवाब देखें

जवाब: Django

Batteries included.

पाठ: Django and FastAPI at a Glance

2. What must you do after startapp for Django to use the app?

  1. Add it to INSTALLED_APPS
  2. Restart the computer
  3. Rename manage.py
  4. Nothing
जवाब देखें

जवाब: Add it to INSTALLED_APPS

Apps are registered in settings.

पाठ: A Django Project and App

3. What status does FastAPI return when a typed parameter cannot be parsed?

  1. 301 Moved
  2. 500 Internal Server Error
  3. 200 OK
  4. 422 Unprocessable Entity
जवाब देखें

जवाब: 422 Unprocessable Entity

Validation errors are 422 by default.

पाठ: A First FastAPI App

FastAPI Core Features

4. What does response_model do with fields not in the model?

  1. Adds them as strings
  2. Removes them from the response
  3. Raises an error
  4. Encrypts them
जवाब देखें

जवाब: Removes them from the response

Output filtering prevents leaks.

पाठ: Request and Response Models With Pydantic

5. How does a dependency reject an unauthenticated request?

  1. By returning None silently
  2. By raising HTTPException with status 401
  3. By printing a warning
  4. By crashing the server
जवाब देखें

जवाब: By raising HTTPException with status 401

Dependencies can short-circuit requests.

पाठ: Dependency Injection With Depends

6. What happens if you call time.sleep(2) inside an async def endpoint?

  1. FastAPI converts it to await
  2. Nothing, it is async
  3. It runs in parallel automatically
  4. It blocks the event loop and stalls other requests
जवाब देखें

जवाब: It blocks the event loop and stalls other requests

Use await asyncio.sleep or async libraries.

पाठ: Async Endpoints

7. Where does FastAPI serve interactive API documentation by default?

  1. /docs
  2. /admin
  3. /swagger.php
  4. Nowhere
जवाब देखें

जवाब: /docs

Swagger UI at /docs, spec at /openapi.json.

पाठ: Automatic OpenAPI Documentation

FastAPI in Practice

8. Which status fits "item is out of stock" for an order request?

  1. 500 Internal Server Error
  2. 200 OK
  3. 409 Conflict
  4. 301 Moved Permanently
जवाब देखें

जवाब: 409 Conflict

The request conflicts with current state.

पाठ: Error Handling

9. How do you replace a database dependency in a FastAPI test?

  1. Disable Pydantic
  2. Edit the source file during the test
  3. Set app.dependency_overrides[get_db] to a fake
  4. Restart uvicorn
जवाब देखें

जवाब: Set app.dependency_overrides[get_db] to a fake

Dependencies make testing easy.

पाठ: Testing With Dependency Overrides

10. Which tool commonly manages schema migrations for SQLAlchemy?

  1. Alembic
  2. Django admin
  3. Pydantic
  4. uvicorn
जवाब देखें

जवाब: Alembic

Migrations are separate from FastAPI.

पाठ: Databases With FastAPI

Django Models and Migrations

11. Which field type should store prices?

  1. IntegerField storing text
  2. FloatField
  3. CharField
  4. DecimalField
जवाब देखें

जवाब: DecimalField

Exact decimal arithmetic.

पाठ: Defining Models

12. What does makemigrations do?

  1. Applies changes to the database
  2. Writes migration files describing model changes
  3. Deletes old data
  4. Starts the server
जवाब देखें

जवाब: Writes migration files describing model changes

migrate applies; makemigrations writes.

पाठ: Creating Migrations

13. What does sqlmigrate do?

  1. Applies all migrations
  2. Prints the SQL for a migration without running it
  3. Deletes migrations
  4. Creates a superuser
जवाब देखें

जवाब: Prints the SQL for a migration without running it

Inspect before applying.

पाठ: Reading the SQL Behind a Migration

14. How does Django know which migrations already ran?

  1. It reruns all migrations every time
  2. It reads file timestamps
  3. It asks the user
  4. It records them in the django_migrations table
जवाब देखें

जवाब: It records them in the django_migrations table

Applied migrations are tracked.

पाठ: Applying Migrations

Querying With the Django ORM

15. When does a QuerySet hit the database?

  1. When it is evaluated, for example iterated, listed, counted or fetched with get
  2. When filter() is called
  3. When the model is imported
  4. Never
जवाब देखें

जवाब: When it is evaluated, for example iterated, listed, counted or fetched with get

QuerySets are lazy.

पाठ: QuerySets: Filtering and Laziness

16. Which method fixes N+1 queries for a ForeignKey?

  1. order_by
  2. prefetch_related only for strings
  3. select_related
  4. distinct
जवाब देखें

जवाब: select_related

Join single-valued relations.

पाठ: Avoiding N+1 Queries

17. What does F("price") * 2 in update() do?

  1. Creates a new field
  2. Loads all rows into Python first
  3. Doubles each row's price in a single SQL statement
  4. Formats the price as text
जवाब देखें

जवाब: Doubles each row's price in a single SQL statement

Computation happens in the database.

पाठ: Aggregation, Q Objects and F Expressions

Django Views, Forms and Data Integrity

18. What does get_object_or_404 do when the object is missing?

  1. Raises Http404, producing a 404 response
  2. Returns None
  3. Creates the object
  4. Returns status 500
जवाब देखें

जवाब: Raises Http404, producing a 404 response

Clean not-found handling.

पाठ: Views and URLs

19. Where do you add a custom validation rule for one field in a Django form?

  1. In the migration file
  2. In urls.py
  3. In settings.py
  4. In a clean_<fieldname> method
जवाब देखें

जवाब: In a clean_<fieldname> method

Field-level clean methods.

पाठ: Forms and Validation

20. What happens to earlier writes in an atomic block when a later write fails?

  1. They stay committed
  2. They are rolled back too
  3. They are duplicated
  4. They are written to a log only
जवाब देखें

जवाब: They are rolled back too

All or nothing.

पाठ: Transactions and Referential Protection

Testing and Security

21. What does Django's TestCase do after each test?

  1. Deletes the database file permanently
  2. Rolls back the database changes
  3. Commits changes to production
  4. Restarts Python
जवाब देखें

जवाब: Rolls back the database changes

Isolated tests.

पाठ: Testing Django Apps

22. Why does the same password produce different hashes?

  1. Hashes include the current time only
  2. The hash function is broken
  3. The password changes
  4. Each hash uses a random salt
जवाब देखें

जवाब: Each hash uses a random salt

Salts defeat precomputed attacks.

पाठ: Password Hashing

23. Which setting must be False in production?

  1. DEBUG
  2. USE_TZ
  3. APPEND_SLASH
  4. INSTALLED_APPS
जवाब देखें

जवाब: DEBUG

Debug pages leak sensitive information.

पाठ: Deployment Security Checks

Deployment and a Checklist

24. Which server type runs FastAPI apps?

  1. The Django admin
  2. A WSGI-only server
  3. An ASGI server such as uvicorn
  4. A static file server
जवाब देखें

जवाब: An ASGI server such as uvicorn

FastAPI is ASGI.

पाठ: ASGI and WSGI Servers

25. What is the most common cause of slow Django or FastAPI endpoints?

  1. Python syntax
  2. The choice of web framework
  3. Inefficient database access
  4. Too few comments
जवाब देखें

जवाब: Inefficient database access

Measure the database first.

पाठ: Performance and Scaling

26. Which item belongs on a Python web backend checklist?

  1. No blocking calls inside async def endpoints
  2. DEBUG=True in production
  3. Plain-text password storage
  4. Skipping migrations review
जवाब देखें

जवाब: No blocking calls inside async def endpoints

Correct, efficient, secure.

पाठ: A Python Web Backend Checklist

← कोर्स पर वापस जाएँ