Professional Documents
Culture Documents
Python Interview Questions
Python Interview Questions
Python Interview Questions
1. What is a List
2. What is a Tuple
3. What is a dictionary
7. Explain Inheritance
8. Explain Normalization
9. Explain Encapsulation
ANSWERS :-
1. As a Python fresher, I understand that a list is a versatile data structure used to store
multiple items in a single variable. It is ordered, mutable, and allows duplicate
elements.
4. Modules are Python files containing reusable code, while packages are directories
containing multiple modules. They help organize and manage code, allowing for
better code structure and reusability.
- Encapsulation: Bundling data and methods that operate on that data within a single unit.
- Inheritance: Ability of a class to inherit properties and behavior from another class.
- Polymorphism: Ability to use a single interface for different data types or objects.
- Abstraction: Hiding the implementation details and showing only the necessary features
of an object.
9. Encapsulation is the bundling of data and methods that operate on that data within
a single unit, typically a class. It hides the internal state of an object and only
exposes the necessary methods to interact with it, promoting data security and
abstraction.
10. Polymorphism refers to the ability of an object to take on multiple forms. In Python,
it can be achieved through method overloading and method overriding, allowing
different classes to implement methods with the same name but different
functionalities.
11. Python has a total of 35 keywords, including ‘if’, ‘else’, ‘for’, ‘while’, ‘class’, ‘def’,
‘import’, ‘from’, ‘try’, ‘except’, ‘finally’, and more.
12. Common built-in data types in Python include integers, floats, strings, lists, tuples,
dictionaries, sets, and booleans.
13. PYTHON and JAVA are both popular programming languages, but they have
differences in syntax, usage, and ecosystem. Python is known for its simplicity,
readability, and versatility, while Java is renowned for its performance, platform
independence, and strong typing.
14. Java is generally faster than Python due to its statically-typed nature and Just-In-
Time (JIT) compilation. However, Python offers simplicity, ease of use, and rapid
development, making it suitable for many applications despite its slower execution
speed.
15. In Python, ‘break’ is used to exit a loop prematurely, ‘continue’ is used to skip the
current iteration and proceed to the next one, and ‘pass’ is a null operation that
serves as a placeholder when no action is required.
17. Decorators in Python are functions that modify the behavior of other functions or
methods. They allow you to add functionality to existing functions dynamically, such
as logging, authentication, or memoization, without modifying their source code.