Python Quizz Test your Python knowledge! 🚀 Take our tech quiz to sharpen your skills, challenge your understanding, and compete with others. Start quizzing today! 1 / 14 1. Which method is used to replace all occurrences of a pattern in a string? re.sub() re.replace() re.findall() re.search() 2 / 14 2. What will be the output of the following code? import re pattern = re.compile(r'(\d{3})-(\d{2})-(\d{4})') match = pattern.match('123-45-6789') print(match.groups()) ('123', '45', '6789') ('123', '456', '789') ('123-45', '6789') ('123-45-6789') 3 / 14 3. Which module is used for JSON manipulation in Python? simplejson json xml ujson 4 / 14 4. Which module is used for creating processes in Python? multiprocessing asyncio threading concurrent.futures 5 / 14 5. Which module is used for debugging in Python? pdb traceback logging debug 6 / 14 6. What will be the output of the following code? import re pattern = re.compile(r'\d+') result = pattern.sub('#', 'My number is 123 and my friend's number is 456') print(result) My number is # and my friend's number is # My number is 123 and my friend's number is # None My number is 123 and my friend's number is 456 7 / 14 7. What will be the output of the following code? import threading def print_numbers(): for i in range(5): print(i) t1 = threading.Thread(target=print_numbers) t2 = threading.Thread(target=print_numbers) t1.start() t2.start() t1.join() t2.join() 0 1 2 3 4 0 1 2 3 4 0 0 1 1 2 2 3 3 4 4 0 1 2 3 4 5 5 5 5 5 8 / 14 8. What will be the output of the following code? import unittest class TestStringMethods(unittest.TestCase): def test_upper(self): self.assertEqual('foo'.upper(), 'FOO') if __name__ == '__main__': unittest.main() Test fails Syntax error Test passes ImportError 9 / 14 9. What is the purpose of the await keyword in Python? To terminate a coroutine To create a coroutine To pause the execution of a coroutine To suspend the execution of a coroutine until the awaited result is available 10 / 14 10. Which of the following is true about Python's garbage collector? All of the above It uses reference counting It uses generational garbage collection It can be manually controlled 11 / 14 11. What is the purpose of the GIL (Global Interpreter Lock) in Python? To handle exceptions To manage memory allocation To allow multiple threads to execute Python bytecodes at once To prevent multiple threads from executing Python bytecodes at once 12 / 14 12. What is the output of the following code? from collections import deque d = deque([1, 2, 3, 4]) d.appendleft(0) d.pop() d.extend([5, 6]) d.rotate(1) print(d) deque([0, 1, 2, 3, 5, 6]) deque([6, 0, 1, 2, 3, 5]) deque([5, 6, 0, 1, 2, 3]) deque([6, 0, 1, 2, 3, 4]) 13 / 14 13. Which module is used for asynchronous programming in Python? threading multiprocessing concurrent.futures asyncio 14 / 14 14. What is the purpose of the __slots__ attribute in a Python class? To initialize a new instance of the class To delete an instance of the class To limit the memory footprint of instances To create a new instance of the class Your score is 0%