SlideShare une entreprise Scribd logo
1  sur  10
Python interview questions for experienced
What is PEP 8?
PEP 8 is a coding convention, a set of recommendation, about how to write
your Python code more readable.
What is pickling and unpickling?
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.
How Python is interpreted?
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.
How memory is managed in Python?
 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.
What are the tools that help to find bugs or perform static analysis?
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.
What are Python decorators?
A Python decorator is a specific change that we make in Python syntax to
alter functions easily.
What is lambda in Python?
It is a single expression anonymous function often used as inline function.
lambda forms in python does not have statements?
A lambda form in python does not have statements as it is used to make new
function object and then return them at runtime.
What is pass in Python?
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.
In Python what are iterators?
In Python, iterators are used to iterate a group of elements, containers like list.
What is unittest in Python?
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.
In Python what is slicing?
A mechanism to select a range of items from sequence types like list, tuple,
strings etc. is known as slicing.
What are generators in Python?
The way of implementing iterators are known as generators. It is a normal
function except that it yields expression in the function.
What is docstring in Python?
A Python documentation string is known as docstring, it is a way of
documenting Python functions, modules and classes.
How can you copy an object in Python?
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.
What is negative index in Python?
Python sequences can be index in positive and negative numbers. For
positive index, 0 is the first index, 1 is the second index and so forth. For
negative index, (-1) is the last index and (-2) is the second last index and so
forth.
How you can convert a number to a string?
In order to convert a number into a string, use the inbuilt function str(). If you
want a octal or hexadecimal representation, use the inbuilt function oct() or
hex().
What is the difference between Xrange and range?
Xrange returns the xrange object while range returns the list, and uses the
same memory and no matter what the range size is.
What is module and package in Python?
In Python, module is the way to structure program. Each Python program file
is a module, which imports other modules like objects and attributes.
The folder of Python program is a package of modules. A package can have
modules or subfolders.
Explain how can you make a Python Script executable on Unix?
To make a Python Script executable on Unix, you need to do two things,
 Script file's mode must be executable and
 the first line must begin with # ( #!/usr/local/bin/python)
Explain how to delete a file in Python?
By using a command os.remove (filename) or os.unlink(filename)
Explain what is the common way for the Flask script to work?
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
Explain how you can access sessions in Flask?
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 modify the session if only it has the secret
key Flask.secret_key.
Explain what is Dogpile effect? How can you prevent this effect?
Dogpile effect is referred to the event when cache expires, and websites are
hit by the multiple requests made by the client at the same time. This effect
can be prevented by using semaphore lock. In this system when value
expires, first process acquires the lock and starts generating new value.
What is the function to randomize the items of a list in-place?
Python has a built-in module called as <random>. It exports a public method
<shuffle(<list>)> which can randomize any input sequence.
import random
list = [2, 18, 8, 4]
print "Prior Shuffling - 0", list
random.shuffle(list)
print "After Shuffling - 1", list
random.shuffle(list)
print "After Shuffling - 2", list
What is the best way to split a string in Python?
We can use Python <split()> function to break a string into substrings based on the
defined separator. It returns the list of all words present in the input string.
test = "I am learning Python."
print test.split(" ")
Program Output.
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.8.2] on linux
['I', 'am', 'learning', 'Python.']
What is the right way to transform a Python string into a list?
In Python, strings are just like lists. And it is easy to convert a string into the list. Simply
by passing the string as an argument to the list would result in a string-to-list conversion.
list("I am learning Python.")
Program Output.
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.8.2] on linux
=> ['I', ' ', 'a', 'm', ' ', 'l', 'e', 'a', 'r', 'n', 'i', 'n',
'g', ' ', 'P', 'y', 't', 'h', 'o', 'n', '.']
How does exception handling in Python differ from Java? Also, list the
optional clauses for a <try-except> block in Python?
Unlike Java, Python implements exception handling in a bit different way. It provides an
option of using a <try-except> block where the programmer can see the error details
without terminating the program. Sometimes, along with the problem, this <try-except>
statement offers a solution to deal with the error.
There are following clauses available in Python language.
1. try-except-finally
2. try-except-else
What do you know about the <list> and <dict> comprehensions?
Explain with an example.
The <List/Dict> comprehensions provide an easier way to create the corresponding
object using the existing iterable. As per official Python documents, the list
comprehensions are usually faster than the standard loops. But it’s something that may
change between releases.
What are the methods you know to copy an object in Python?
Commonly, we use <copy.copy()> or <copy.deepcopy()> to perform copy operation on
objects. Though not all objects support these methods but most do.
But some objects are easier to copy. Like the dictionary objects provide a <copy()>
method.
Can you write code to determine the name of an object in Python?
No objects in Python have any associated names. So there is no way of getting the one
for an object. The assignment is only the means of binding a name to the value. The
name then can only refer to access the value. The most we can do is to find the
reference name of the object.
What is the result of the below lines of code?
Here is the example code.
def fast (items= []):
items.append (1)
return items
print fast ()
print fast ()
The above code will give the following result.
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.8.2] on linux
[1]
[1, 1]
The function <fast> evaluates its arguments only once after the function gets defined.
However, since <items> is a list, so it’ll get modified by appending a <1> to it.
What is the result of the below Python code?
keyword = 'aeioubcdfg'
print keyword [:3] + keyword [3:]
Ans. The above code will produce the following result.
<'aeioubcdfg'>
In Python, while performing string slicing, whenever the indices of both the slices collide,
a <+> operator get applied to concatenates them.
How would you produce a list with unique elements from a list with
duplicate elements?
Ans. Iterating the list is not a desirable solution. The right answer should look like this.
duplicates =
['a','b','c','d','d','d','e','a','b','f','g','g','h']
uniqueItems = list(set(duplicates))
print sorted(uniqueItems)
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.8.2] on linux
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
Can you iterate over a list of words and use a dictionary to keep track
of the frequency(count) of each word? Consider the below example.
{'Number':Frequency, '2':2, '3':2}
Ans. Please find out the below code.
def dic(words):
wordList = {}
for index in words:
try:
wordList[index] += 1
except KeyError:
wordList[index] = 1
return wordList
wordList='1,3,2,4,5,3,2,1,4,3,2'.split(',')
print wordList
print dic(wordList)
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.8.2] on linux
['1', '3', '2', '4', '5', '3', '2', '1', '4', '3', '2']
{'1': 2, '3': 3, '2': 3, '5': 1, '4': 2}
What is the result of the following Python code?
class Test(object):
def __init__(self):
self.x = 1
t = Test()
print t.x
print t.x
print t.x
print t.x
Ans. All print statement will display <1>. It’s because the value of object’s attribute(x) is
never changing.
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.8.2] on linux
1
1
1
1
Also, <x> becomes a part of the public members of class Test.
Hence, it can be accessed directly.
Can you describe what’s wrong with the below code?
testProc([1, 2, 3]) # Explicitly passing in a list
testProc() # Using a default empty list
def testProc(n = []):
# Do something with n
print n
Ans. The above code would throw a <NameError>.
The variable n is local to the function <testProc> and can’t be accessed outside.
So, printing it won’t be possible.

Contenu connexe

Tendances

Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming LanguageMansiSuthar3
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Codemotion
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid DeconstructionKevlin Henney
 
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Ranel Padon
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundationKevlin Henney
 
The Awesome Python Class Part-5
The Awesome Python Class Part-5The Awesome Python Class Part-5
The Awesome Python Class Part-5Binay Kumar Ray
 

Tendances (20)

Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
Python Session - 5
Python Session - 5Python Session - 5
Python Session - 5
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid Deconstruction
 
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
 
Python training
Python trainingPython training
Python training
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Python Session - 2
Python Session - 2Python Session - 2
Python Session - 2
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
 
Python second ppt
Python second pptPython second ppt
Python second ppt
 
The Awesome Python Class Part-5
The Awesome Python Class Part-5The Awesome Python Class Part-5
The Awesome Python Class Part-5
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 

Similaire à Python Interview Questions For Experienced

Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answerskavinilavuG
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning ParrotAI
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfExaminationSectionMR
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questionsgokul174578
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdfalaparthi
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdfsamiwaris2
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfDatacademy.ai
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2sadhana312471
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_pythongunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptMohitChaudhary637683
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptxrohithprabhas1
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizeIruolagbePius
 

Similaire à Python Interview Questions For Experienced (20)

Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdf
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdf
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Python master class 2
Python master class 2Python master class 2
Python master class 2
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
Core python programming tutorial
Core python programming tutorialCore python programming tutorial
Core python programming tutorial
 

Plus de zynofustechnology

JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3zynofustechnology
 
PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4zynofustechnology
 
PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2zynofustechnology
 
Java Interview Questions - 1
Java Interview Questions - 1Java Interview Questions - 1
Java Interview Questions - 1zynofustechnology
 
SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experiencedzynofustechnology
 
Software Testing Interview Questions For Experienced
Software Testing Interview Questions For ExperiencedSoftware Testing Interview Questions For Experienced
Software Testing Interview Questions For Experiencedzynofustechnology
 
Digital marketing questions -3
Digital marketing questions -3Digital marketing questions -3
Digital marketing questions -3zynofustechnology
 
Digital marketing questions -2
Digital marketing questions -2Digital marketing questions -2
Digital marketing questions -2zynofustechnology
 
Digital marketing questions 1
Digital marketing questions  1Digital marketing questions  1
Digital marketing questions 1zynofustechnology
 

Plus de zynofustechnology (13)

JAVA QUESTIONS -6
JAVA QUESTIONS -6JAVA QUESTIONS -6
JAVA QUESTIONS -6
 
JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3
 
PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4
 
PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2
 
JAVA INTERVIEW QUESTIONS -3
JAVA INTERVIEW QUESTIONS -3JAVA INTERVIEW QUESTIONS -3
JAVA INTERVIEW QUESTIONS -3
 
Java Interview Questions-5
Java Interview Questions-5Java Interview Questions-5
Java Interview Questions-5
 
Java Interview Questions - 1
Java Interview Questions - 1Java Interview Questions - 1
Java Interview Questions - 1
 
SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experienced
 
Software Testing Interview Questions For Experienced
Software Testing Interview Questions For ExperiencedSoftware Testing Interview Questions For Experienced
Software Testing Interview Questions For Experienced
 
HR interview questions
HR interview questionsHR interview questions
HR interview questions
 
Digital marketing questions -3
Digital marketing questions -3Digital marketing questions -3
Digital marketing questions -3
 
Digital marketing questions -2
Digital marketing questions -2Digital marketing questions -2
Digital marketing questions -2
 
Digital marketing questions 1
Digital marketing questions  1Digital marketing questions  1
Digital marketing questions 1
 

Dernier

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 

Dernier (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 

Python Interview Questions For Experienced

  • 1. Python interview questions for experienced What is PEP 8? PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable. What is pickling and unpickling? 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. How Python is interpreted? 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. How memory is managed in Python?  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. What are the tools that help to find bugs or perform static analysis? 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.
  • 2. What are Python decorators? A Python decorator is a specific change that we make in Python syntax to alter functions easily. What is lambda in Python? It is a single expression anonymous function often used as inline function. lambda forms in python does not have statements? A lambda form in python does not have statements as it is used to make new function object and then return them at runtime. What is pass in Python? 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. In Python what are iterators? In Python, iterators are used to iterate a group of elements, containers like list. What is unittest in Python? 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. In Python what is slicing? A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing. What are generators in Python? The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function.
  • 3. What is docstring in Python? A Python documentation string is known as docstring, it is a way of documenting Python functions, modules and classes. How can you copy an object in Python? 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. What is negative index in Python? Python sequences can be index in positive and negative numbers. For positive index, 0 is the first index, 1 is the second index and so forth. For negative index, (-1) is the last index and (-2) is the second last index and so forth. How you can convert a number to a string? In order to convert a number into a string, use the inbuilt function str(). If you want a octal or hexadecimal representation, use the inbuilt function oct() or hex(). What is the difference between Xrange and range? Xrange returns the xrange object while range returns the list, and uses the same memory and no matter what the range size is. What is module and package in Python? In Python, module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes. The folder of Python program is a package of modules. A package can have modules or subfolders. Explain how can you make a Python Script executable on Unix? To make a Python Script executable on Unix, you need to do two things,  Script file's mode must be executable and  the first line must begin with # ( #!/usr/local/bin/python)
  • 4. Explain how to delete a file in Python? By using a command os.remove (filename) or os.unlink(filename) Explain what is the common way for the Flask script to work? 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 Explain how you can access sessions in Flask? 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 modify the session if only it has the secret key Flask.secret_key. Explain what is Dogpile effect? How can you prevent this effect? Dogpile effect is referred to the event when cache expires, and websites are hit by the multiple requests made by the client at the same time. This effect can be prevented by using semaphore lock. In this system when value expires, first process acquires the lock and starts generating new value. What is the function to randomize the items of a list in-place? Python has a built-in module called as <random>. It exports a public method <shuffle(<list>)> which can randomize any input sequence. import random list = [2, 18, 8, 4]
  • 5. print "Prior Shuffling - 0", list random.shuffle(list) print "After Shuffling - 1", list random.shuffle(list) print "After Shuffling - 2", list What is the best way to split a string in Python? We can use Python <split()> function to break a string into substrings based on the defined separator. It returns the list of all words present in the input string. test = "I am learning Python." print test.split(" ") Program Output. Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux ['I', 'am', 'learning', 'Python.'] What is the right way to transform a Python string into a list? In Python, strings are just like lists. And it is easy to convert a string into the list. Simply by passing the string as an argument to the list would result in a string-to-list conversion. list("I am learning Python.") Program Output. Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux
  • 6. => ['I', ' ', 'a', 'm', ' ', 'l', 'e', 'a', 'r', 'n', 'i', 'n', 'g', ' ', 'P', 'y', 't', 'h', 'o', 'n', '.'] How does exception handling in Python differ from Java? Also, list the optional clauses for a <try-except> block in Python? Unlike Java, Python implements exception handling in a bit different way. It provides an option of using a <try-except> block where the programmer can see the error details without terminating the program. Sometimes, along with the problem, this <try-except> statement offers a solution to deal with the error. There are following clauses available in Python language. 1. try-except-finally 2. try-except-else What do you know about the <list> and <dict> comprehensions? Explain with an example. The <List/Dict> comprehensions provide an easier way to create the corresponding object using the existing iterable. As per official Python documents, the list comprehensions are usually faster than the standard loops. But it’s something that may change between releases. What are the methods you know to copy an object in Python? Commonly, we use <copy.copy()> or <copy.deepcopy()> to perform copy operation on objects. Though not all objects support these methods but most do. But some objects are easier to copy. Like the dictionary objects provide a <copy()> method. Can you write code to determine the name of an object in Python? No objects in Python have any associated names. So there is no way of getting the one for an object. The assignment is only the means of binding a name to the value. The name then can only refer to access the value. The most we can do is to find the reference name of the object. What is the result of the below lines of code? Here is the example code.
  • 7. def fast (items= []): items.append (1) return items print fast () print fast () The above code will give the following result. Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux [1] [1, 1] The function <fast> evaluates its arguments only once after the function gets defined. However, since <items> is a list, so it’ll get modified by appending a <1> to it. What is the result of the below Python code? keyword = 'aeioubcdfg' print keyword [:3] + keyword [3:] Ans. The above code will produce the following result. <'aeioubcdfg'> In Python, while performing string slicing, whenever the indices of both the slices collide, a <+> operator get applied to concatenates them.
  • 8. How would you produce a list with unique elements from a list with duplicate elements? Ans. Iterating the list is not a desirable solution. The right answer should look like this. duplicates = ['a','b','c','d','d','d','e','a','b','f','g','g','h'] uniqueItems = list(set(duplicates)) print sorted(uniqueItems) Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] Can you iterate over a list of words and use a dictionary to keep track of the frequency(count) of each word? Consider the below example. {'Number':Frequency, '2':2, '3':2} Ans. Please find out the below code. def dic(words): wordList = {} for index in words: try: wordList[index] += 1 except KeyError: wordList[index] = 1
  • 9. return wordList wordList='1,3,2,4,5,3,2,1,4,3,2'.split(',') print wordList print dic(wordList) Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux ['1', '3', '2', '4', '5', '3', '2', '1', '4', '3', '2'] {'1': 2, '3': 3, '2': 3, '5': 1, '4': 2} What is the result of the following Python code? class Test(object): def __init__(self): self.x = 1 t = Test() print t.x print t.x print t.x print t.x
  • 10. Ans. All print statement will display <1>. It’s because the value of object’s attribute(x) is never changing. Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux 1 1 1 1 Also, <x> becomes a part of the public members of class Test. Hence, it can be accessed directly. Can you describe what’s wrong with the below code? testProc([1, 2, 3]) # Explicitly passing in a list testProc() # Using a default empty list def testProc(n = []): # Do something with n print n Ans. The above code would throw a <NameError>. The variable n is local to the function <testProc> and can’t be accessed outside. So, printing it won’t be possible.