Python - MCQ

Multiple Choice Questions


Share with a Friend

 

Python MCQ - File I/O Handling and Exception Handling - Set 37

6. which of the following command is used to open a file “c:\temp.txt” in append-mode? 
A). outfile = open(“c:\\temp.txt”, “a”)
B). outfile = open(“c:\\temp.txt”, “rw”)
C). outfile = open(“c:\temp.txt”, “w+”)
D). outfile = open(“c:\\temp.txt”, “r+”)
View Answer
Correct: A


7. Which of the following commands can be used to read “n” number of characters from a file using the file object
A). file.read(n)
B). n = file.read()
C). file.readline(n)
D). file.readlines()
View Answer
Correct: A


8. Which of the following commands can be used to read the next line in a file using the file object
A). tmpfile.read(n)
B). tmpfile.read()
C). tmpfile.readline()
D). tmpfile.readlines()
View Answer
Correct: C


9. What does the method returns? 
A). str
B). a list of lines
C). list of single characters
D). list of integers
View Answer
Correct: B


10. Which of the following functions can be used to check if a file “logo” exists? 
A). os.path.isFile(logo)
B). os.path.exists(logo)
C). os.path.isfile(logo)
D). os.isFile(logo)
View Answer
Correct: C



 
 
 
   
   
   
UltraInfo Technologies
ITDeveloper