Python Interview Questions
A list of top frequently asked Python interview questions
and answers are given below.
1)What is Python?
Python is a high level object-oriented programming language
with objects, modules, threads, exceptions and automatic
memory management. It is asimple yet powerful
programming language. It can run equally on different
platforms such as Windows, inux, UNIX, Macintosh etc. Thus,
Python is a portable language.
2) What are the advantages of Python?
Following are the main advantages of using Python.
" Free and open source
" Portable
" Extensible
" Object oriented
" Built-in data structure
3)What is PEP 8?
PEP 8 is a coding convention which specifies a set of
guidelines, about how to write your Python code more
readable.
4) What is used to create Unicode string in
Python?
You should use "Unicode" before the string. For example:
Unicode (text).
5) Explain how Python is interpreted?
Python is an interpreted language. The Python language
program runs directly from the source code. It converts the
source code into an intermediate language, which is again
translated into machine language that has to be executed.
6) How memory is managed in Python?
Memory is managed in Python in following way:
" Memory is managed in Python by 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.
" Python memory manager is responsible for allocating Python
heap space for Python objects.
" 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.
7) What is Python decorator?
A Python decorator is a specific change made within Python
syntax to alter functions easily.
8) What are the rules for local and global
variable in Python?
InPython, variables that are only referenced inside a function
are called implicitly global. Ifa variable is assigned a new
value anywhere within the function's body, it's assumed to be
a local. If a variable is ever assigned a new value inside the
function, the variable is implicitly local, and you need to
explicitly declare it as 'global'.
9) What is namespace in Python?
InPython, every name has a place where 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.
10) What are iterators in Python?
In Python, iterators are used to iterate a group of elements,
containers like list.
11) What is generator in Python?
In Python, generator is a way that specifies how to implement
iterators. It is a normal function except that it yields
expression in the function.
12)What is slicing in Python?
A list of top frequently asked Python interview questions
and answers are given below.
1)What is Python?
Python is a high level object-oriented programming language
with objects, modules, threads, exceptions and automatic
memory management. It is asimple yet powerful
programming language. It can run equally on different
platforms such as Windows, inux, UNIX, Macintosh etc. Thus,
Python is a portable language.
2) What are the advantages of Python?
Following are the main advantages of using Python.
" Free and open source
" Portable
" Extensible
" Object oriented
" Built-in data structure
3)What is PEP 8?
PEP 8 is a coding convention which specifies a set of
guidelines, about how to write your Python code more
readable.
4) What is used to create Unicode string in
Python?
You should use "Unicode" before the string. For example:
Unicode (text).
5) Explain how Python is interpreted?
Python is an interpreted language. The Python language
program runs directly from the source code. It converts the
source code into an intermediate language, which is again
translated into machine language that has to be executed.
6) How memory is managed in Python?
Memory is managed in Python in following way:
" Memory is managed in Python by 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.
" Python memory manager is responsible for allocating Python
heap space for Python objects.
" 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.
7) What is Python decorator?
A Python decorator is a specific change made within Python
syntax to alter functions easily.
8) What are the rules for local and global
variable in Python?
InPython, variables that are only referenced inside a function
are called implicitly global. Ifa variable is assigned a new
value anywhere within the function's body, it's assumed to be
a local. If a variable is ever assigned a new value inside the
function, the variable is implicitly local, and you need to
explicitly declare it as 'global'.
9) What is namespace in Python?
InPython, every name has a place where 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.
10) What are iterators in Python?
In Python, iterators are used to iterate a group of elements,
containers like list.
11) What is generator in Python?
In Python, generator is a way that specifies how to implement
iterators. It is a normal function except that it yields
expression in the function.
12)What is slicing in Python?