Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. To open a file c:\scores.txt for appending data, we use
a. outfile = open(“c:\\scores.txt”, “a”)
b. outfile = open(“c:\\scores.txt”, “rw”)
c. outfile = open(file = “c:\\scores.txt”, “w”)
d. outfile = open(file = “c:\\scores.txt”, “w”)
Q. Which of the following statements are true?
a. when you open a file for reading, if the file does not exist, an error occurs
b. when you open a file for writing, if the file does not exist, a new file is created
c. when you open a file for writing, if the file exists, the existing file is overwritten with the new file
d. all of the mentioned
Q. 1 TEXT FILES, READING AND WRITING FILES, FORMAT OPERATOR
a. infile.read(2)
b. infile.read()
c. infile.readline()
d. infile.readlines()
Q. To read the remaining lines of the file from a file object infile, we use
a. infile.read(2)
b. infile.read()
c. infile.readline()
d. infile.readlines()
Q. 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
Q. What is the use of tell() method in python?
a. tells you the current position within the file
b. tells you the end position within the file
c. tells you the file is opened or not
d. none of the mentioned
Q. What is the current syntax of rename() a file?
a. rename(current_file_name, new_file_name)
b. rename(new_file_name, current_file_name,)
c. rename(()(current_file_name, new_file_name))
d. none of the mentioned
Q. What is the current syntax of remove() a file?
a. remove(file_name)
b. remove(new_file_name, current_file_name,)
c. remove(() , file_name))
d. none of the mentioned
Q. What is the use of seek() method in files?
a. sets the file’s current position at the offset
b. sets the file’s previous position at the offset
c. sets the file’s current position within the file
d. none of the mentioned
Q. What is the use of truncate() method in file?
a. truncates the file size
b. deletes the content of the file
c. deletes the file size
d. none of the mentioned
Q. Which is/are the basic I/O connections in file?
a. standard input
b. standard output
c. standard errors
d. all of the mentioned
Q. sys.stdout.write('Python\n')
a. compilation error
b. runtime error
c. hello python d)
d. hello python