0% found this document useful (0 votes)
0 views2 pages

Python Interview Questions

The document provides a compilation of common Python interview questions and answers, covering key features, data types, memory management, and differences between various concepts like lists and tuples, deep and shallow copies, and 'is' vs '=='. It also explains decorators, multithreading, generators, and lambda functions. This resource serves as a guide for candidates preparing for Python-related interviews.

Uploaded by

51vinaympps12sa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

Python Interview Questions

The document provides a compilation of common Python interview questions and answers, covering key features, data types, memory management, and differences between various concepts like lists and tuples, deep and shallow copies, and 'is' vs '=='. It also explains decorators, multithreading, generators, and lambda functions. This resource serves as a guide for candidates preparing for Python-related interviews.

Uploaded by

51vinaympps12sa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Interview Questions and Answers

1. What are Python's key features?


- Easy to learn and use
- Interpreted language
- Dynamically typed
- Extensive standard library
- Supports object-oriented, procedural, and functional programming
- Portable and cross-platform
- Huge community support

2. What is the difference between list and tuple in Python?


- Lists are mutable while tuples are immutable.
- Lists have variable length; tuples have fixed length.
- Lists consume more memory; tuples are memory efficient.
- Tuples are faster than lists.

3. Explain Python's memory management.


- Python uses private heap space to manage memory.
- It has an in-built garbage collector.
- Reference counting and cyclic garbage collector are used.

4. What are Python decorators?


- Decorators are functions that modify the behavior of another function.
- Commonly used in logging, access control, instrumentation, etc.
- Defined with the @decorator_name syntax.

5. What is the difference between 'is' and '=='' in Python?


- '==' checks value equality.
- 'is' checks reference (object identity) equality.

6. How does Python handle multithreading?


- Python supports multithreading using the threading module.
- Due to the Global Interpreter Lock (GIL), true parallelism is limited.
- Best suited for I/O-bound rather than CPU-bound tasks.

7. What are Python's data types?


- Numeric types: int, float, complex
- Sequence types: list, tuple, range
- Text type: str
- Set types: set, frozenset
- Mapping type: dict
- Boolean type: bool
- None type: NoneType
8. What is the difference between deep copy and shallow copy?
- Shallow copy creates a new object but references the original nested objects.
- Deep copy creates a new object and recursively copies all nested objects.
- Use copy.copy() for shallow copy and copy.deepcopy() for deep copy.

9. What are Python generators?


- Generators are iterators that yield items one at a time using the 'yield' keyword.
- More memory efficient for large datasets.
- Maintains state between iterations.

10. What are lambda functions?


- Anonymous, inline functions defined using the 'lambda' keyword.
- Syntax: lambda arguments: expression

You might also like