Intermediate Python Concepts

Test your grasp of functions,modules,and object-oriented programming.

1. What is the output of [x**2 for x in range(3)]?
2. Which of the following are valid ways to handle exceptions in Python?
3. A generator function returns a generator object when called, not the yielded values directly.
4. What keyword is used to define a decorator in Python (when applying it to a function)?
5. Which method is required to make a class iterable?
6. Which of the following are examples of Python context managers?
7. Lambda functions in Python can contain multiple return statements.
8. What is the output of: list(filter(lambda x: x%2==0, [1,2,3,4]))
9. What does the 'super()' function do in Python?
10. Which of the following are immutable data types in Python?
11. Type hints in Python are enforced at runtime by default.
12. What term describes a function that takes another function as an argument and returns a new function?
13. Which syntax creates a generator expression?
14. Which methods must an iterator implement?
15. Python supports multiple inheritance (a class inheriting from multiple parents).
16. What is the output of: ''.join(['P', 'y', 't', 'h', 'o', 'n'])
17. What is the role of the 'yield' keyword in a function?
18. Which are valid ways to create a dictionary?
19. The 'finally' block in try/except runs only if an exception occurs.
20. What built-in function returns the type of an object?
Answered 0 of 0 — 0 correct