Interview Questions
Interview Questions
Q.JWT?
Q.size of the
Q.PostgreSQL trigger?
The triggers can be used to authenticate the input data.
It can easily retrieve the system functions.
CREATE Trigger
ALTER Trigger
DROP Trigger
ENABLE Trigger
DISABLE Triggercfdtr
it occurs when specific event occurs
Q.python memory management?
Python uses the dynamic memory allocation which is managed by the Heap data
structure.
It has stack and heap.in stack variables are stored and objects are stored in heap
memory.
if objects does not have any ref variable then it is eligible for GC
Q.what is a module in Python?
python file having some executable python code
it having functions and statements to
module makes the code easier understand and use.
Q.diff between charfield and text field?
CharField has a max_length of 255 characters while TextField can hold more than 255
characters.
Q.Http Request and Response?
Client give request.server gives response
Q.select related and Fetched related?
select related is always goto database and check for the request & give the response
fetch related is goto DB only once after that it will give the response for next time
Q.append and extend?
append takes the list as a element and add to end of the list
extend takes all the elements and add all the elements to end of the list
Q.Django Architecture?
Q.Relationships in Django?
Many-to Many:multiple authors and multiple users
one to one:one user to one author
one to many:one author many users
Q.diff between read() and readline()
read() reads all of the file's contents into a string, readline reads just a single line from
the file
Q.Trigger?
these are executed automatically in place or after data modifications.
before insert,after insert,before update,after update,before delete ,after delete
before:trigger activated before delete the recorn from table
after delete:trigger activated after delete the record from table
Q.group?
group function is used on the set of rows and gives one result per group
we use group functions at avg,count,max,min,sum
Q.relations in SQL?
one to one relationship:one record is related with another record in table b
one to many:one record is related with many record in table b
many to one:many records related with one record in table b
Q.merge?
conditional
Q.wht sql?
perform caluculations,manipulations
Q.highest salary of employee from employee table?
SELECT TOP 1 salary FRom
(SELECT top 3 salary from employee order by DESC)
order by ASC;
Q.CLAUSE?
limit the result,filter the rows
Q.Having and where?
Having is only applied with select statement.it is usually used in gruop by clause
where is aplied to each row before they are not part of group by clause
Q.How can you fetch records from two tables?
by using INTERSECT
ex:select studentid from studenttable InTERSECT select empid from emptable;
Q.manipulation functions?
upper,lower,
Q.agreegate function?
used to evaluate mathematical expressions and returns single value
Q.like operator?
is used for pattern matching
1. What is the use of Middlewares in Django?
Middlewares in Django is a lightweight plugin that processes during request and response
execution. It performs functions
like security, CSRF protection, session, authentication, etc.
Django supports various built-in middlewares.
1.SecurityMiddleware
2.SessionMiddleware
3.CommonMiddleware
4.CsrfViewMiddleware
5.AuthenticationMiddleware
6.MessageMiddleware
2. What is the difference between CharField and TextField in Django?
TextField is a large text field for large-sized text. In Django, TextField is used to store
paragraphs and all other text data.
The default form widget for this field is TextArea.
CharField is a string field used for small- to large-sized strings. It is like a string field in
C/C++. In Django,
CharField is used to store small strings like first name, last name, etc
3.Describe Django Field Class types?
Every field in a model is an instance of the appropriate field class. In Django, field class
types determine:
The column type describes the database about what kind of data to store (e.g.,
INTEGER, VARCHAR, TEXT).
The default HTML widget, while rendering a form field
4.What is the usage of "Django-admin.py" and "manage.py"?
Django-admin.py - It is a command-line utility for administrative tasks.
manage.py - It is automatically created in each Django project and controls the Django
project on the server or even to begin one.
It has the following usage:
Manages the project's package on the sys. path.
5.What are signals in Django?
Django provides a set of built-in signals that enable users to get notified of specific
actions.
pre_save
pre_delete
signals.request_started
6.What’s the difference between a project and an app in Django?
The app is a module that deals with the dedicated requirements in a project. On the
other hand, the project covers an entire app.
In Django terms, a project can contain different apps, while an app features in various
projects.
7.Explain Django URL in brief?
Django allows you to design URL functions however you want. For this, you need to
create a Python module informally called URLconf (URL configuration).
This module is purely a Python code and acts as a mapping between URL path
expressions and Python functions.
Django also provides a way to translate URLs according to the active language.
8.What are Django Exceptions?
ObjectDoesNotExist,FieldDoesNotExist,SuspiciousOperation,PermissionDenied,ViewDoesNotExi
st,MiddlewareNotUsed,ImproperlyConfigured,
FieldError,ValidationError.
9.Explain Django session
Django uses the session to keep track of the state between the site and a particular
browser. Django supports anonymous sessions.
The session framework stores and retrieves data on a per-site-visitor basis. It stores the
information on the server side and supports sending and
receiving cookies. Cookies store the data of session ID but not the actual data itself.
10.What are Django cookies?
A cookie is a piece of information stored in the client's browser. To set and fetch
cookies, Django provides built-in methods.
We use the set_cookie() method for setting a cookie and the get() method for getting
the cookie.
You can also use the request.COOKIES['key'] array to get cookie values.
11.Flask vs. Django: What's the difference between Flask & Django?
Flask and Django are the two most popular Python web frameworks.
Django:
High-level Python web framework for easy and simple projects.
Full-stack web framework
Templates, Admin, and ORM are Built-in
Django does not support visual debugging.
Django Web Framework supports a large number of third-party applications.
Flask:
Low-level Python web framework.
WSGI (Web Server Gateway Interface ) framework
Templates, Admin, and ORM are Built-in Requires installation
Flask Web Framework doesn't offer support for third-party applications.
Flask supports visual debugging.
12. How to check the version of Django installed on your system?
To check the version of Django installed on your system, open the command prompt
and enter the following command:
py -m django --version
13.Give a brief about Django Admin.
Django Admin is the command-line utility for administrative tasks. It's a preloaded
interface to fulfill all web developer's needs and is imported from the
"django.contrib packages".
Django Admin interface has its user authentication and offers advanced features like
authorizing the access, CMS (Content Management System),
managing various models, etc.
14.How do you create a Django project?
To create a Django project, navigate to the directory where you want to do a project
and type the following command:
django-admin startproject ABC
That will create an "ABC" folder with the following structure −
ABC/
manage.py
myproject/
__init__.py
settings.py
urls.py
wsgi.py
15.Name some companies using Django.
Various companies out there are using Django. Of them, major are Instagram, Pinterest,
Udemy, Mozilla Firefox, Reddit, etc.
16.How do Django views work?
Django views are the critical component of the framework They serve the purpose of
encapsulation. They encapsulate the logic liable
to process a user's request and return a response to the user.
Either they return HTTP responses or raise an exception such as 404 in Django. Besides,
Views also perform tasks like reading records from a database,
generating PDF files, etc.
Every app in Django comes with a views.py file, and this contains the views functions.
Views function can be imported directly in the URLs file in Django.
To achieve that, you have to import the view function in the urls.py file first and add the
path/URL that the browser should request to call that View function.
17.Give a brief about Django Template?
Django Templates generate dynamic web pages. Using templates, you can show the
static data and the data from various databases connected to the app
through a context dictionary. You can create any number of templates based on project
requirements. Even it's OK to have none of them.
Django template engine handles the templating in the Django web framework. Some
template syntaxes declare variables, filters, control logic, and comments.
Django ships built-in backends for its template system called the Django template
language (DTL).
18.Describe Django ORM.
interact with databases in a more pythonic way like we can avoid writing raw queries, it
is possible to retrieve, save,
delete and perform other operations over the database without ever writing any SQL
query. It works as an abstraction
layer between the models and the database.
19.When to use iterators in Django ORM?
Iterators are containers in Python containing several elements. Every object in the
iterator implements two methods that are __init__() and the __next__()
methods.
In Django, the fair use of an iterator is when you process results that take up a large
amount of memory space. For this, you can use the iterator() method,
which evaluates the QuerySet and returns the corresponding iterator over the results.
1 .what is decorator:-
A.decorator in py are essential functions that add functionality to an existing function
in py without changing the structure of
the function itself.
program of decorator:-
def shout(text):
return text.upper()
def load(text):
return text.lower()
def greet(fun)
#storing the function in a variable
a=fun("thr kfhif")
print(a)
greet(shout)
greet(load)
2.what is GENERATOR:
A Generator function is defined like a NORMAL FUNCTION .but whenever it needs to
generate a value,So with the YIELD KEYWORD rather than return..
program of generator:-
def simpleGeneratorFun():
yield 1
yield 2
yield 3
OUTPUT;-
1
2
3
3.what is CONSTRUCTOR?
CONSTRUCTOR are special type of method used to Initialize an object. And constructor are
responsible for assigning values to the data member of a class
when the object is created.
def __init__(self):
# body of the constructor
7.WHAT IS EXCEPTION?
AN Unwanted and unexpected event which disturbs normal flow of program is called
exception .
9.WHAT IS YIELD?
The Yield keyword in Python is similar to a return statement used for returning values.
However, there is a slight difference.
The yield statement returns a generator object to the one who calls the function which
contains yield, instead of simply returning a value.
15.WHAT IS CLASS?
TO create objects we require some models are plans or blueprint.we can write a class to
represent properties and action.
properties can be represented by variables.action can be represented by method.
16.WHAT IS OBJECT?
Object is an instance of a class.
17.WHAT IS INHERITANCE? INHERITS properties from base class to derived class
1.single inheritance
2.multiple inheritance
3.multilevel inheritance
4.hierarchical inheritance
18.WHAT IS ABSTRACTION?
Abstraction is nothing but that shows only essential attributes and hides unnecessary
information to the users.
19.WHAT IS ENCAPSULATION?
Binding data together method and data in a single unit is called encapsulation.
20.WHAT IS POLYMORPHISM?
Polymorphism is a method in oops,that performs different things as per object class.
24)Mention what are the rules for local and global variables in Python?
Local variables: If a variable is assigned a new value anywhere within the function's body, it's
assumed to be local.
Global variables: Those variables that are only referenced inside a function are implicitly global.
34)what is module?
39)what is decorator?
41)what is abstraction ?
42)what is encapsulation?
43) what is pickling and unpickling?
44)explain how delete file in python?
45)what are built in datatypes that are present in python?
46)Explainhow can you make a python script executable on unix?
47)what is the difference between flask and Django?
48)what is the common way for flask script to work?
49)what are iterators in python?
50)what is garbage collector in python?
51)what is multithreading and multiprocessing?
Sample DataFrame:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthew',
'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Sample Solution :
Python Code :
import pandas as pd
import numpy as np
df = pd.DataFrame(exam_data , index=labels)
print("First three rows of the data frame:")
print(df.iloc[:3])
Sample Output:
3. I have a json file called userdata.json and I have an object for user1 and user2. For that user1
and user2 has a key : value pair of firstname and lastname . write a script to modify the data of
userdata.json file and add two more key : value pairs to each json object called location and
mail id and return me the json file. What are the steps?
4. What is pickling?
5. What is lambda?
12. Write a model to get the username and password, in the backend also it will integrate the
database?
15. What is the difference between git clone and git remote?
17. What are the Agile ceremonies that you have been involved in?
19. Analytical Question - Time - 3 : 50. What is the angle between the hour and minute hand?
1.what is pythonpath ?
6.what is Decorator ?
7.What is PEP-8 ?
1. Create a dictionary with keys and values and change the key as value and value is key
2. Create a list with some numbers write a function to find the second minimum
3. Create a class with constructor with an id and initialize the id and create two objects
with different numbers, then you need to add the objects and get the sum of two id’s
4. Can you explain the left join in sql
5. Can you explain the outer join
6. Can you explain multithreading
7. When do you use multithreading and when do you use multiprocessing
8. Any example for multiprocessing
9. Real world example for multithreading and multiprocessing
10. Can you explain generate function
11. Why should I use generate instead of normal function
12. Can you explain method overriding and overloading
13. Can you explain why should I use exception handling
14. Do you know about dockers
15. What is your current role in your project
Examples:
1)T=6, K=3, D=15
1.[3,10,15]
2)T=1, K=1, D10
1.[1,2,3,4,5,6,7,8,9,10]
3)T=2, K=1, D=10
1[1,4,5,8,9,12,13,16,17,20,21,24,25,28,29,32,33,36,37]
4)T=11, K=5, D=100
[5,18,27,40,49,62,71,84,93]
Sol)
def onmyCallDays(T,K,D):
lst=[]
for I in range(D//T):
if i%2==0:
lst.append(K+T*i)
else:
lst.append(lst[-1]+(T-K)*2+1)
return lst
print(onmyCallDays(11,5,100))
output:
[5,18,27,40,49,62,71,84,93]
2) How to call API URL using python and print only headers.
1.What is Django
2.where do you define data base collection in Django
3.can I have multiple DB connection
4.what is difference between get and filter method in Django
5.input=[hello world] o/p [h:1,e:1,l:3,o:2,w:1,r:1,d:1] write a code for that
6.what is polymorphism
7.what is the types of polymorphism explain
8.do you have polymorphism in python
9.what are the types of inheritance explain
10.suppose if I have class A class B class c which will be execute
11.what is MRO
12.what is abstract class
13.how do you whether class is abstract or not explain with examples
14.explain try, except, else, finally
15.what will happen to the code if you don’t use try& exception
16.in Django we have mixins signals, explain
17.why we will use debug=”true” in the project production level
1. Give me a brief introduction about your first project optum clinical manager
2. What is the role in this project
3. Were you involve designing this project
4. What exactly you do while developing the webpages
5. How do you create a Django app
6. How do you deploy a Django webapp
7. How do you print hello world by searching the /hello
8. "Design/Develop for a document management system that requires the following
feature set.
1. Introduce yourself
2. What is the difference between list and tuple
3. Can you explain the set data structure
4. What is the difference between constructor and a method
5. How many types of functions in python
6. Can you please differentiate interface and abstraction class
7. D = {“A”:[1,2,3,4],”B”:[2,4],”c”:4} the output should be only integer not a
list ..output:- c 4
8. a = [10,20,30,40,50] you need to square all the elements in the list, using the list
comprehension
9. What do you mean by dataframe in pandas
10. Why we need to go for pandas
11. What is the main difference between drop and delete
12. How can you rename the table name
13. How can you delete a row which is having employee salary 50,000
14. What is the use of primary key constraint
15. I would like to add another column to an existing table how can you do that
16. What is the use of git basically
17. Suppose you working on a child branch, I am also working on the same branch, so
can get conflict or not
2. We have a employee table we need to update address and phone no in a record, so you can
write the logic by using the Rest_API’s in Django
3. Can you tell me the difference between list and tuple
4. Where we use the list and tuple
5. What is the difference between filter and map functions
6. What is a decorator
7. Can you write the decorator function with time caluculation
NHCL
9)What is Docstring?
11)What is Matrix?