MCQs Practice Portal - thefunword.com

Python MCQ Quiz Hub

Python Mcq Set 17

Choose a topic to test your knowledge and improve your Python skills

1. The process of pickling in Python includes:




2. To sterilize an object hierarchy, the _____________ function must be called. To desterilize a data stream, the ______________ function must be called.




3. Pick the correct statement regarding pickle and marshal modules.




4. What will be the output of the following Python code? pickle.HIGHEST_PROTOCOL




5. Which of the following Python codes will result in an error? object = ‘a’




6. Which of the following functions can be used to find the protocol version of the pickle module currently being used?




7. Which of the following functions can accept more than one positional argument?




8. Which of the following functions raises an error when an unpicklable object is encountered by Pickler?




9. The pickle module defines ______ exceptions and exports _______ classes.




10. Which of the following cannot be pickled?




11. If __getstate__() returns _______________ the __setstate__() module will not be called on pickling.




12. Lambda functions cannot be pickled because:




13. The module _____ is a comparatively faster implementation of the pickle module.




14. The copy module uses the ________ protocol for shallow and deep copy.




15. Which module in Python supports regular expressions?




16. Which of the following creates a pattern object?




17. What does the function re.match do?




18. What does the function re.search do?




19. What will be the output of the following Python code? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.groups())




20. What will be the output of the following Python code? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.group())




21. What will be the output of the following Python code? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.group(2))




22. What will be the output of the following Python code? sentence = 'horses are fast' regex = re.compile('(?P<animal>w+) (?P<verb>w+) (?P<adjective>w+)') matched = re.search(regex, sentence) print(matched.groupdict())




23. What will be the output of the following Python code? sentence = 'horses are fast' regex = re.compile('(?P<animal>w+) (?P<verb>w+) (?P<adjective>w+)') matched = re.search(regex, sentence) print(matched.groups())




24. What will be the output of the following Python code? sentence = 'horses are fast' regex = re.compile('(?P<animal>w+) (?P<verb>w+) (?P<adjective>w+)') matched = re.search(regex, sentence) print(matched.group(2))




25. The character Dot (that is, ‘.’) in the default mode, matches any character other than _______




26. The expression a{5} will match _____ characters with the previous regular expression.




27. ______ matches the start of the string. ________ matches the end of the string.




28. What will be the output of the following Python code? re.split('W+', 'Hello, hello, hello.')




29. What will be the output of the following Python function? re.findall("hello world", "hello", 1)




30. Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match=’aaaa’>.




31. Which of the following functions clears the regular expression cache?




32. What will be the output of the following Python code? import re re.ASCII




33. Which of the following functions results in case insensitive matching?




34. What will be the output of the following Python code? re.compile('hello', re.X)




35. What will be the output of the following Python code? re.split('[a-c]', '0a3B6', re.I)




36. What will be the output of the following Python code? re.sub('morning', 'evening', 'good morning')




37. What will be the output of the following Python code? re.escape('new**world')




38. What will be the output of the following Python code? re.fullmatch('hello', 'hello world')




39. The difference between the functions re.sub and re.subn is that re.sub returns a _______ whereas re.subn returns a ______




40. What will be the output of the following Python code? re.split('mum', 'mumbai*', 1)




41. What will be the output of the following Python code? re.split(r'(nd)=', 'n1=3.1, n2=5, n3=4.565')




42. The function of re.search is ____




43. Which of the following functions creates a Python object?




44. Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression?




45. What will be the output of the following Python code? s = 'welcome home' m = re.match(r'(.*)(.*?)', s) print(m.group())




46. The function of re.match is _______




47. The special character B matches the empty string, but only when it is ____




48. Which of the following special characters matches a pattern only at the end of the string?




49. What will be the output of the following Python code? re.match('sp(.*)am', 'spam')




50. Which of the following special characters represents a comment (that is, the contents of the parenthesis are simply ignores)?