Python - MCQ
Multiple Choice Questions
Python MCQ - File I/O Handling and Exception Handling - Set 36
1. What will be the output of print(10,20,30,sep="/")
A). 10 20 30
B). 10/20/30
C). 10\20\30
D). error
View Answer
Correct: B
2. What will be the output of print("{0} is a diploma portal",format("cwipedia"))
A). {0} is a diploma portal
B). 0 is a diploma portal
C). error
D). cwipedia is a diploma portal
View Answer
Correct: D
3. What are the two built-in functions to read a line of text from standard input, which is by default the keyboard?
A). Raw_input
B). Input
C). Read
D). Scanner
View Answer
Correct: A, B
4. Which of the following command is used to open a file “c:\temp.txt” in read-mode only?
A). infile = open(“c:\temp.txt”, “r”)
B). infile = open(“c:\\temp.txt”, “r”)
C). infile = open(file = “c:\temp.txt”, “r+”)
D). infile = open(file = “c:\\temp.txt”, “r+”)
View Answer
Correct: B
5. Which of the following command is used to open a file “c:\temp.txt” in write-mode only?
A). outfile = open(“c:\temp.txt”, “w”)
B). outfile = open(“c:\\temp.txt”, “w”)
C). outfile = open(file = “c:\temp.txt”, “w+”)
D). outfile = open(file = “c:\\temp.txt”, “w+”)
View Answer
Correct: B