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. 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-45', '6789') ('123-45-6789') ('123', '456', '789') 2 / 14 2. Which module is used for JSON manipulation in Python? json ujson simplejson xml 3 / 14 3. Which method is used to replace all occurrences of a pattern in a string? re.sub() re.findall() re.search() re.replace() 4 / 14 4. Which module is used for asynchronous programming in Python? concurrent.futures multiprocessing threading asyncio 5 / 14 5. 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, 4]) deque([6, 0, 1, 2, 3, 5]) deque([5, 6, 0, 1, 2, 3]) 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) None My number is # and my friend's number is # My number is 123 and my friend's number is 456 My number is 123 and my friend's number is # 7 / 14 7. What is the purpose of the GIL (Global Interpreter Lock) in Python? To allow multiple threads to execute Python bytecodes at once To manage memory allocation To handle exceptions To prevent multiple threads from executing Python bytecodes at once 8 / 14 8. Which module is used for creating processes in Python? multiprocessing asyncio concurrent.futures threading 9 / 14 9. 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 5 5 5 5 5 0 0 1 1 2 2 3 3 4 4 0 1 2 3 4 0 1 2 3 4 10 / 14 10. What is the purpose of the __slots__ attribute in a Python class? To create a new instance of the class To delete an instance of the class To limit the memory footprint of instances To initialize a new instance of the class 11 / 14 11. 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 passes ImportError Syntax error Test fails 12 / 14 12. What is the purpose of the await keyword in Python? To suspend the execution of a coroutine until the awaited result is available To create a coroutine To terminate a coroutine To pause the execution of a coroutine 13 / 14 13. Which module is used for debugging in Python? debug pdb traceback logging 14 / 14 14. Which of the following is true about Python's garbage collector? It uses reference counting All of the above It uses generational garbage collection It can be manually controlled Your score is 0%