Solu ons/Python interview ques ons and answers
Newest RATED A+ 2025/2026
what is python? - Answers Python-high level, interac ve object-oriented
scrip ng language
Features of Python - Answers -func onal programming f(x)
-structure programming, ifs, fors, whiles
-OOP (object oriented programming)
-Can be compiled to byte-code for building
-supports automa c garabage collec on
-easly integrated with other languages, c,c++,java
What is PYTHONPATH - Answers place where all the modules are stored to call from and
includes the python source library
What is PYTHONSTARTUP? - Answers It contains the path of an ini aliza on file containing
Python source code. It is executed every me you start the interpreter. It is named as
.pythonrc.py in Unix and it contains commands that load u li es or modify PYTHONPATH.
PYTHONCASEOK - Answers It is used in Windows to instruct Python to find the first case-
insensi ve match in an import statement. Set this variable to any value to ac vate it.
PYTHONHOME - Answers It is an alterna ve module search path. It is usually embedded in the
PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.
Data Types of Python - Answers Numbers, strings, lists, tuple, dic onary
, what is a tuple - Answers A blank consists of a number of values separated by commas. Unlike
lists, however, blank are enclosed within parentheses, and cannot be updated,
dic onaries - Answers kind of hash table type,They work like associa ve arrays or hashes found
in Perl and consist of key-value pairs, A blank key can be almost any Python type, but are usually
numbers or strings. Values, on the other hand, can be any arbitrary Python object.
unichr(x) - Answers Converts an integer to a Unicode character.
ord(x) - Answers Converts a single character to its integer value.
// - Answers floor divison
is operator - Answers Evaluates to true if the variables on either side of the operator point to
the same object and false otherwise. x is y, here is results in 1 if id(x) equals id(y).
not in - Answers Evaluates to true if the variables on either side of the operator point to the
same object and false otherwise. x is y, here is results in 1 if id(x) equals id(y).
con nue statement - Answers Causes the loop to skip the remainder of its body and
immediately retest its condi on prior to reitera ng.
choice(x) - Answers Returns a random item from a list, tuple, or string.
seed([x]) - Answers Sets the integer star ng value used in genera ng random numbers. Call
this func on before calling any other random module func on. Returns None.
,shuffle(lst) - Answers How to shuffle a list
alphanumeric - Answers contains le>ers and words
join(seq) - Answers Merges (concatenates) the string representa ons of elements in sequence
seq into a string, with separator string.
str.replace(old, new [, max]) - Answers Replaces all occurrences of old in string with new or at
most max occurrences if max given.
list.index(obj) - Answers Returns the lowest index in list that obj appears.
cmp(list1, list2) - Answers Compares elements of both lists.
difference between del() and remove() methods of list - Answers aList = [123, 'xyz', 'zara', 'abc',
'xyz'];
aList.remove('xyz'); (object)
del list_item[4] (index)
list.insert(index, obj) - Answers Inserts object obj into list at offset index.
list.pop(obj=list[-1]) - Answers Removes and returns last object or obj from list.
list.reverse() - Answers Reverses objects of list in place.
list.sort([func]) - Answers Sorts objects of list, use compare func if given.
, zip() - Answers creates a lists of tuples from two lists
Top 40 Python Interview Ques ons
Func on help - Answers help(str.replace)
1) What is Python? What are the benefits of using Python? - Answers Python is a
programming language with objects, modules, threads, excep ons and automa c
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.
2) What is PEP 8? - Answers PEP 8 is a coding conven on, a set of recommenda on, about
how to write your Python code
more readable.
3) What is pickling and unpickling? - Answers Pickle module accepts any Python object and
converts it into a string representa on and dumps
it into a file by using dump func on, this process is called pickling. While the process of
retrieving original Python objects from the stored string representa on is called unpickling.
4) How Python is interpreted? - Answers Python language is an interpreted language. Python
program runs directly from the source
code. It converts the source code that is wri>en by the programmer into an intermediate
language, which is again translated into machine language that has to be executed.
5) How memory is managed in Python? - Answers 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