Complete Python Interview QA
Complete Python Interview QA
Basic Python
Q: What are Python's key features?
A: Python 3 is the future and has better Unicode support, print is a function, and integer division
A: Python code is executed line by line by the interpreter rather than being compiled into machine
language beforehand.
A: Variables are containers for storing data. You declare them simply by assigning a value: `x = 5`.
A: Common types include int, float, str, bool, list, tuple, set, dict, and NoneType.
A: Type casting converts data from one type to another using functions like int(), float(), str().
A: *args allows variable number of positional arguments; **kwargs allows variable number of
keyword arguments.
A: `is` checks for object identity, `==` checks for value equality.
Data Structures
Q: What are the different built-in data structures in Python?
Control Flow
Q: How do `if`, `elif`, and `else` statements work?
Functions
Q: How do you define a function in Python?
A: Use the `def` keyword followed by the function name and parentheses.
A: `global` accesses variables in the global scope; `nonlocal` accesses variables in the enclosing
function scope.
A: `staticmethod` doesnt use class or instance, `classmethod` takes cls, instance methods take self.
Error Handling
Q: How does exception handling work in Python?
File Handling
Q: How do you read and write files in Python?
Pythonic Concepts
Q: What is slicing in Python?
Advanced Concepts
Q: Explain GIL (Global Interpreter Lock).