Docsity

Inside the Python Interview | What Recruiters Expect You to Know, Exams of Software Engineering

Toggle sidebar
bg1
INSIDE THE PYTHON INTERVIEW / TECHNICAL REVIEW
Python Interview Review • 1
INSIDE THE PYTHON INTERVIEW
Core Concepts, Coding Questions & Framework Fundamentals
INTERVIEW QUESTIONS & SOURCE ANSWERS
REFERENCE NOTE Function help help(str.replace)
01 What is Python? What are the benefits of using Python?
ANSWER Python is a programming language with objects, modules, threads, exceptions and automatic memory
management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure
and it is an open source.
02 What is PEP 8?
ANSWER PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more
readable.
03 What is pickling and unpickling?
ANSWER Pickle module accepts any Python object and converts it into a string representation and dumps it into a
file by using dump function, this process is called pickling. While the process of retrieving original Python objects
from the stored string representation is called unpickling.
04 How Python is interpreted?
ANSWER Python language is an interpreted language. Python program runs directly from the source code. It
converts the source code that is written by the programmer into an intermediate language, which is again
translated into machine language that has to be executed.
05 How memory is managed in Python?
ANSWER Python memory is managed by Python private heap space. All Python objects and data structures are
located in a private heap. The programmer does not have an access to this private heap and interpreter takes care
of this Python private heap. The allocation of Python heap space for Python objects is done by Python memory
manager. The core API gives access to some tools for the programmer to code. Python also have an inbuilt garbage
collector, which recycle all the unused memory and frees the memory and makes it available to the heap space.
06 What are the tools that help to find bugs or perform static analysis?
ANSWER PyChecker is a static analysis tool that detects the bugs in Python source code and warns about the style
and complexity of the bug. Pylint is another tool that verifies whether the module meets the coding standard.
07 What are Python decorators?
ANSWER A Python decorator is a specific change that we make in Python syntax to alter functions easily.
08 What is the difference between list and tuple?
ANSWER The difference between list and tuple is that list is mutable while tuple is not. Tuple can be hashed for
e.g as a key for dictionaries.
pf3
pf4

Partial preview of the text

Download Inside the Python Interview | What Recruiters Expect You to Know and more Exams Software Engineering in PDF only on Docsity!

INSIDE THE PYTHON INTERVIEW

Core Concepts, Coding Questions & Framework Fundamentals

INTERVIEW QUESTIONS & SOURCE ANSWERS

REFERENCE NOTE Function help help(str.replace) 01 What is Python? What are the benefits of using Python? ANSWER Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source. 02 What is PEP 8? ANSWER PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable. 03 What is pickling and unpickling? ANSWER Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using dump function, this process is called pickling. While the process of retrieving original Python objects from the stored string representation is called unpickling. 04 How Python is interpreted? ANSWER Python language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed. 05 How memory is managed in Python? ANSWER Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap. The allocation of Python heap space for Python objects is done by Python memory manager. The core API gives access to some tools for the programmer to code. Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space. 06 What are the tools that help to find bugs or perform static analysis? ANSWER PyChecker is a static analysis tool that detects the bugs in Python source code and warns about the style and complexity of the bug. Pylint is another tool that verifies whether the module meets the coding standard. 07 What are Python decorators? ANSWER A Python decorator is a specific change that we make in Python syntax to alter functions easily. 08 What is the difference between list and tuple? ANSWER The difference between list and tuple is that list is mutable while tuple is not. Tuple can be hashed for e.g as a key for dictionaries.

09 How are arguments passed by value or by reference? ANSWER Everything in Python is an object and all variables hold references to the objects. The references values are according to the functions as a result you cannot change the value of the references. However, you can change the objects if it is mutable. 10 What is Dict and List comprehensions are? ANSWER They are syntax constructions to ease the creation of a Dictionary or List based on existing iterable. 11 What are the built-in type does python provides? ANSWER There are mutable and Immutable types of Pythons built in types Mutable built-in types List Sets Dictionaries Immutable built-in types Strings Tuples Numbers 12 What is namespace in Python? ANSWER In Python, every name introduced has a place where it lives and can be hooked for. This is known as namespace. It is like a box where a variable name is mapped to the object placed. Whenever the variable is searched out, this box will be searched, to get corresponding object. 13 What is lambda in Python? ANSWER It is a single expression anonymous function often used as inline function. 1 4 Why lambda forms in python does not have statements? ANSWER A lambda form in python does not have statements as it is used to make new function object and then return them at runtime. 15 What is pass in Python? ANSWER Pass means, no-operation Python statement, or in other words it is a place holder in compound statement, where there should be a blank left and nothing has to be written there. 16 In Python what are iterators? ANSWER In Python, iterators are used to iterate a group of elements, containers like list. 17 What is unittest in Python? ANSWER A unit testing framework in Python is known as unittest. It supports sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections etc. 18 In Python what is slicing? ANSWER A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing. 19 What are generators in Python? ANSWER The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function. 20 What is docstring in Python? ANSWER A Python documentation string is known as docstring, it is a way of documenting Python functions, modules and classes. 21 How can you copy an object in Python? ANSWER To copy an object in Python, you can try copy.copy () or copy.deepcopy() for the general case. You cannot copy all objects but most of them.

34 Mention the use of the split function in Python? ANSWER The use of the split function in Python is that it breaks a string into shorter strings using the defined separator. It gives a list of all words present in the string. 35 Explain what is Flask & its benefits? ANSWER Flask is a web micro framework for Python based on "Werkzeug, Jinja 2 and good intentions" BSD licensed. Werkzeug and jingja are two of its dependencies. Flask is part of the micro-framework. Which means it will have little to no dependencies on external libraries. It makes the framework light while there is little dependency to update and less security bugs. 36 Mention what is the difference between Django, Pyramid, and Flask? ANSWER Flask is a "microframework" primarily build for a small application with simpler requirements. In flask, you have to use external libraries. Flask is ready to use. Pyramid are build for larger applications. It provides flexibility and lets the developer use the right tools for their project. The developer can choose the database, URL structure, templating style and more. Pyramid is heavy configurable. Like Pyramid, Django can also used for larger applications. It includes an ORM. 37 Mention what is Flask-WTF and what are their features? ANSWER Flask-WTF offers simple integration with WTForms. Features include for Flask WTF are Integration with wtforms Secure form with csrf token Global csrf protection Internationalization integration Recaptcha supporting File upload that works with Flask Uploads 38 Explain what is the common way for the Flask script to work? ANSWER The common way for the flask script to work is Either it should be the import path for your application Or the path to a Python file 39 Explain how you can access sessions in Flask? ANSWER A session basically allows you to remember information from one request to another. In a flask, it uses a signed cookie so the user can look at the session contents and modify. The user can. 40 Is Flask an MVC model and if yes give an example showing MVC pattern for your application? ANSWER Basically, Flask is a minimalistic framework which behaves same as MVC framework. So MVC is a perfect fit for Flask, and the pattern for MVC we will consider for the following example