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