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