Python Quiz

1. Which of the following is used to create a generator in Python?

2. What is the purpose of the __init__ method in a Python class?

3. Which of the following is a mutable data type in Python?

4. What is the purpose of the try...except block in Python?

5. Which function is used to open a file in Python?

6. What does the *args parameter in a function definition allow?

7. Which of the following modules is used for regular expressions in Python?

8. What is the purpose of the __name__ == '__main__' condition?

9. Which function is used to get the length of a list or string in Python?

10. What is the purpose of the with statement in Python?

11. Which of the following is an immutable data type in Python?

12. What does the lambda keyword do in Python?

13. Which method is used to add an element to the end of a list in Python?

14. What is the purpose of the pass statement in Python?

15. Which method is used to remove an element from a specific index in a list?

16. What is the purpose of the __str__ method in a Python class?

17. Which module is used for working with operating system dependent functionality?

18. What does the **kwargs parameter in a function definition allow?

19. Which method is used to remove the first occurrence of a specific value from a list?

20. What is the purpose of the enumerate() function in Python?