0% found this document useful (0 votes)
3 views3 pages

Python Interview Q&A: Key Concepts Explained

The document provides a comprehensive overview of Python interview questions and answers, covering key features, data types, data structures, functions, object-oriented programming, modules, exception handling, file handling, advanced concepts, and popular libraries. It highlights important distinctions such as mutable vs immutable types, the use of decorators, and the significance of generators and coroutines. Additionally, it discusses the Global Interpreter Lock (GIL) and the concept of virtual environments.

Uploaded by

g2176149
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)
3 views3 pages

Python Interview Q&A: Key Concepts Explained

The document provides a comprehensive overview of Python interview questions and answers, covering key features, data types, data structures, functions, object-oriented programming, modules, exception handling, file handling, advanced concepts, and popular libraries. It highlights important distinctions such as mutable vs immutable types, the use of decorators, and the significance of generators and coroutines. Additionally, it discusses the Global Interpreter Lock (GIL) and the concept of virtual environments.

Uploaded by

g2176149
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

Python Interview Questions & Answers

1. Basics

- Python's Key Features: Easy syntax, interpreted, dynamic typing, OOP support, standard library.

- Data Types: int, float, str, bool, list, tuple, set, dict, None, bytes.

- 'is' vs '==': 'is' checks identity; '==' checks value.

- Mutable vs Immutable: Mutable - list, dict, set. Immutable - int, float, str, tuple.

- Memory Management: Automatic GC, reference counting.

2. Data Structures

- List vs Tuple vs Set vs Dict:

List: ordered, mutable.

Tuple: ordered, immutable.

Set: unordered, unique items.

Dict: key-value pairs.

- Use Tuple: For fixed data.

- Iterate Dict: for k,v in [Link]()

- Remove Duplicates: list(set(my_list))

3. Functions

- *args/**kwargs: *args for positional, **kwargs for keyword args.

- Lambda: Anonymous function (e.g. lambda x: x*x)

- Deep vs Shallow Copy: Deep copies all levels, shallow copies top level only.

- Decorator: Wraps another function to modify behavior.

4. OOP

- Class/Object: Class is blueprint; object is instance.


- Inheritance Types: Single, Multiple, Multilevel, Hierarchical, Hybrid.

- @staticmethod/@classmethod: static - no self/cls; classmethod - uses cls.

- OOP Concepts: Encapsulation (data hiding), Polymorphism (many forms), Abstraction (hide

complexity).

5. Modules & Packages

- Module: Python file. Package: folder with __init__.py.

- Import: import math / from math import sqrt

- __init__.py: Marks directory as package.

6. Exception Handling

- try/except: Handle errors.

- try/finally: Code in finally always runs.

- Custom Exception: class MyError(Exception): pass

7. File Handling

- Read/Write: with open("[Link]", "r") as f: data = [Link]()

- Modes: r, w, a, rb, etc.

8. Advanced

- Generator: Uses yield; lazy eval.

- Coroutine: yield + send()

- GIL: Global Interpreter Lock, restricts threads.

- Metaclass: Class of a class.

9. Libraries & Tools

- Libraries: NumPy, Pandas, requests, Flask, Django.


- virtualenv: Isolated Python environments.

You might also like