Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views2 pages

Interview Questions Answers

The document contains a series of interview questions and answers related to Python, Django, and web development concepts. Key topics include differences between `is` and `==`, Django models, form validation, middleware, and token-based authentication. It also covers HTML attributes, Flexbox, JavaScript closures, and version control with Git.

Uploaded by

algo47177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Interview Questions Answers

The document contains a series of interview questions and answers related to Python, Django, and web development concepts. Key topics include differences between `is` and `==`, Django models, form validation, middleware, and token-based authentication. It also covers HTML attributes, Flexbox, JavaScript closures, and version control with Git.

Uploaded by

algo47177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Interview Questions & Answers

Q: What is the difference between `is` and `==` in Python?

A: `is` checks object identity; `==` checks value equality.

Q: What will this code output and why?

A: list1: [10, 'a'] (shared default list)

list2: [123] (separate list)

list3: [10, 'a']

Q: Explain what a Python decorator is and give a simple example.

A: A decorator modifies function behavior.

Example:

@decorator

def func(): ...

Q: What are Django models and how are they related to the database?

A: Models define DB schema; each model = a table.

Q: How does Django handle form validation in class-based views?

A: With FormMixin methods like form_valid() and form_invalid().

Q: Difference between `@login_required` and permission-based views?

A: `@login_required`: checks authentication; permissions check specific rights.

Q: Role of `MIDDLEWARE` in Django

A: Middleware processes requests/responses globally (e.g., auth, sessions).

Q: Difference between `ForeignKey`, `OneToOneField`, `ManyToManyField`

A: FK: many-to-one; O2O: one-to-one; M2M: many-to-many.

Q: What are serializers in DRF and why are they needed?

A: Convert model data to/from JSON, enforce validation.


Q: How to implement token-based authentication in DRF?

A: Install rest_framework.authtoken, use TokenAuthentication.

Q: HTTP status codes for success, not found, validation error?

A: Success: 200/201; Not Found: 404; Validation Error: 400.

Q: Difference between `id` and `class` in HTML?

A: `id` is unique; `class` is reusable.

Q: How does Flexbox work? Give a real-world use-case.

A: Distributes space in a row/column. E.g., responsive navbar.

Q: Explain what a JavaScript closure is.

A: Function retains access to its lexical scope.

Q: JS function that fetches data from an API and logs it:

A: async function fetchData() {

const res = await fetch(...);

const data = await res.json();

console.log(data);

Q: Difference between `git pull` and `git fetch`?

A: `fetch`: updates refs; `pull`: fetch + merge.

Q: Deploying a Django project to Render or Railway - steps?

A: Push code, connect repo, set env vars, configure build, deploy.

Q: What are environment variables and why important in deployment?

A: Store config/secrets outside code for safety and flexibility.

You might also like