Python Questions and Answers – Files – 5

This set of Python written test Questions & Answers focuses on “Files”. 1. Which of the following is not a valid mode to open a file? a) ab b) rw c) r+ d) w+ 2. What is the difference between r+ and w+ modes? a) no difference b) in r+ the pointer is initially placed … Read more

advertisement

Python Questions and Answers – Files – 4

This set of Python Scripting Interview Questions & Answers focuses on “Files”. 1. In file handling, what does this terms means “r, a”? a) read, append b) append, read c) write, append d) none of the mentioned 2. What is the use of “w” in file handling? a) Read b) Write c) Append d) None … Read more

advertisement

Python Questions and Answers – Files – 3

This set of Python Scripting Questions & Answers focuses on “Files”. 1. Which is/are the basic I/O connections in file? a) Standard Input b) Standard Output c) Standard Errors d) All of the mentioned 2. What will be the output of the following Python code? (If entered name is sanfoundry) import sysprint ‘Enter your name: … Read more

advertisement

Python Questions and Answers – Files – 2

This set of Python Certification Questions & Answers focuses on “Files”. 1. Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard? a) Raw_input & Input b) Input & Scan c) Scan & Scanner d) Scanner 2. What will be the output of … Read more

advertisement

Python Questions and Answers – Files – 1

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “files”. 1. To open a file c:\scores.txt for reading, we use _____________ a) infile = open(“c:\scores.txt”, “r”) b) infile = open(“c:\\scores.txt”, “r”) c) infile = open(file = “c:\scores.txt”, “r”) d) infile = open(file = “c:\\scores.txt”, “r”) 2. To open a file c:\scores.txt for … Read more

advertisement

Python Questions and Answers – Regular Expressions – 5

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expressions – 5”. 1. Which of the following functions returns a dictionary mapping group names to group numbers? a) re.compile.group b) re.compile.groupindex c) re.compile.index d) re.compile.indexgroup 2. Which of the following statements regarding the output of the function re.match is incorrect? a) … Read more

advertisement

Python Questions and Answers – Regular Expressions – 4

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expressions – 4”. 1. What will be the output of the following Python code? re.split(r'(a)(t)’, ‘Maths is a difficult subject’) a) [‘M a t h s i s a d i f f i c u l t s u b j … Read more

advertisement

Python Questions and Answers – Regular Expressions – 3

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expressions – 3”. 1. What will be the output of the following Python code? re.split(r'(n\d)=’, ‘n1=3.1, n2=5, n3=4.565’) a) Error b) [”, ‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] c) [‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] d) [‘3.1, ‘, … Read more

advertisement

Python Questions and Answers – Regular Expressions – 2

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expressions – 2”. 1. What will be the output of the following Python code? re.compile(’hello’, re.X) a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] b) re.compile(‘hello’, re.VERBOSE) c) Error d) Junk value 2. What will be the output of the following Python code? re.split('[a-c]’, … Read more

advertisement

Python Questions and Answers – Regular Expressions – 1

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expressions – 1”. 1. The character Dot (that is, ‘.’) in the default mode, matches any character other than _____________ a) caret b) ampersand c) percentage symbol d) newline 2. The expression a{5} will match _____________ characters with the previous regular expression. … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.