Direction: Choose the correct option
Q1.
What is a context manager in Python?
Direction: Choose the correct option
Q2.
Which statement is used to invoke a context manager?
Direction: Choose the correct option
Q3.
What does the `__enter__` method do?
Direction: Choose the correct option
Q4.
What does the `__exit__` method do?
Direction: Choose the correct option
Q5.
How can you create a context manager using a generator?
Direction: Choose the correct option
Q6.
What is the purpose of `with open('file.txt') as f:`?
Direction: Choose the correct option
Q7.
What happens if an exception occurs inside the `with` block?
Direction: Choose the correct option
Q8.
What does the `as` clause in `with ... as` do?
Direction: Choose the correct option
Q9.
Which library provides the `contextmanager` decorator?
Direction: Choose the correct option
Q10.
What is the purpose of `contextlib.closing`?
