PYTHON INTERVIEW QUESTIONS
How are arguments passed in a Python method?
Every argument in a Python method is an Object. All the variables in Python have reference to an Object. Therefore arguments in Python method are passed by Reference. Since some of the objects passed as reference are mutable, we can change those objects in a method. But for an Immutable object like String, any change…
What is a Python Decorator?
A Python Decorator is a mechanism to wrap a Python function and modify its behavior by adding more functionality to it. We can use @ symbol to call a Python Decorator function.
What is the difference between a Tuple and List in Python?
In Python, Tuple and List are built-in data structures. Some of the differences between Tuple and List are as follows: I. Syntax: A Tuple is enclosed in parentheses: E.g. myTuple = (10, 20, “apple”); A List is enclosed in brackets: E.g. myList = [10, 20, 30]; II. Mutable: Tuple is an immutable data structure. Whereas,…
How will you perform Static Analysis on a Python Script?
We can use Static Analysis tool called PyChecker for this purpose.PyChecker can detect errors in Python code.PyChecker also gives warnings for any style issues.Some other tools to find bugs in Python code are pylint and pyflakes.
How does memory management work in Python?
There is a private heap space in Python that contains all the Python objects and data structures. In CPython there is a memory manager responsible for managing the heap space. There are different components in Python memory manager that handle segmentation, sharing, caching, memory pre-allocation etc. Python memory manager also takes care of garbage collection…
What is Pickling in Python?
Pickling is a process by which a Python object hierarchy can be converted into a byte stream. The reverse operation of Pickling is Unpickling. Python has a module named pickle. This module has the implementation of a powerful algorithm for serialization and de-serialization of Python object structure. Some people also call Pickling as Serialization or…
PYTHON INTERVIEW QUESTIONS
PYTHON INTERVIEW QUESTIONS