Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer

From 136 to 150 of 820

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”)

  • a. outfile = open(“c:\\scores.txt”, “a”)

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

  • 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()

  • a. infile.read(2)

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()

  • d. infile.readlines()

Q. print(f.closed)

a. true

b. false

c. none

d. error

  • a. true

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

  • a. raw_input & input

Q. Which one of the following is not attributes of file?

a. closed

b. softspace

c. rename

d. mode

  • c. rename

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

  • a. tells you the current position within the file

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

  • a. rename(current_file_name, new_file_name)

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

  • a. remove(file_name)

Q. fo.close()

a. compilation error

b. syntax error

c. displays output

d. none of the mentioned

  • c. displays output

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

  • a. sets the file’s current position at the offset

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

  • a. truncates the file size

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

  • d. all of the mentioned

Q. sys.stdout.write('Python\n')

a. compilation error

b. runtime error

c. hello python d)

d. hello python

  • d. hello python
Subscribe Now

Get All Updates & News