Questions

M.C.Q

🎯

Test yourself on this topic

19 questions · timed · auto-graded

MCQ 11 Mark
What is the correct syntax of open() function?
  • A
    File = open(file_name[, access_mode][, buffering])
  •  File object = open(file_name [, access_mode][,buffering])
  • C
    File object = open(file_name)
  • D
     None of the above
Answer
Correct option: B.
 File object = open(file_name [, access_mode][,buffering])
 File object = open(file_name [, access_mode][,buffering])
View full question & answer
MCQ 21 Mark
Which of the following are the attributes related to a file object?
  • A
    Closed
  • B
    Mode
  • C
    Filename
  • $(a)$ and $(b)$
Answer
Correct option: D.
$(a)$ and $(b)$
$(a)$ and $(b)$
View full question & answer
MCQ 31 Mark
Which of the following functions do you use to write data in the binary format?
  • A
    Write 
  • B
    Output
  • Dump
  • D
    Send
Answer
Correct option: C.
Dump
Dump
View full question & answer
MCQ 41 Mark
Which of the following command is used to open a file "d:temp.txt" for writing in binary format only?
  • A
    fout = open("d:story.txt", "wb")
  • fout = open("d:temp.txt", "wb")
  • C
    fout = open(file = "d:temp.txt", "wb+")
  • D
     fout = open(file = "d:temp.txt", "wb+")
Answer
Correct option: B.
fout = open("d:temp.txt", "wb")
fout = open("d:temp.txt", "wb")
View full question & answer
MCQ 51 Mark
What does the method returns?
  • A
     Str
  • A list of lines
  • C
    List of single characters
  • D
    List of integers
Answer
Correct option: B.
A list of lines
A list of lines
View full question & answer
MCQ 61 Mark
Which of the following commands can be used to read the next line in a file using the file object ?
  • A
    File.read(n)
  • B
    File.read()
  • File.readline()
  • D
     File.readlines()
Answer
Correct option: C.
File.readline()
File.readline()
View full question & answer
MCQ 71 Mark
Which of the following commands can be used to read "n" number of characters from a file using the file object ?
  • File.read(n)
  • B
    N = file.read()
  • C
    File.readline(n)
  • D
     File.readlines()
Answer
Correct option: A.
File.read(n)
File.read(n)
View full question & answer
MCQ 81 Mark
Which of the following statement is not true regarding the opening modes of a file?
  • 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, an error occurs.
  •  When you open a file for reading, if the file does not exist, the program will open an empty file
  • D
    When you open a file for writing, if the file does not exist, a new file is created.
Answer
Correct option: C.
 When you open a file for reading, if the file does not exist, the program will open an empty file
 When you open a file for reading, if the file does not exist, the program will open an empty file
View full question & answer
MCQ 91 Mark
What is the pickling?
  • It is used for object serialization
  • B
     It is used for object deserialization
  • C
    None of the mentioned
  • D
    All of the mentioned
Answer
Correct option: A.
It is used for object serialization
It is used for object serialization
View full question & answer
MCQ 101 Mark
What is the syntax of remove() a file in python?
  • remove(file_name)
  • B
    remove(new_file_name, current_file_name,)
  • C
     remove(() , file_name))
  • D
    none of these
Answer
Correct option: A.
remove(file_name)
remove(file_name)
View full question & answer
MCQ 111 Mark
What is the use of tell() method in python?
  • 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 these
Answer
Correct option: A.
tells you the current position within the file
tells you the current position within the file
View full question & answer
MCQ 121 Mark
seek() method in files used for
  • 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 these
Answer
Correct option: A.
sets the file's current position at the offset
sets the file's current position at the offset
View full question & answer
MCQ 131 Mark
What is the syntax of rename() a file?
  • 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 these
Answer
Correct option: A.
rename(current_file_name, new_file_name)
rename(current_file_name, new_file_name)
View full question & answer
MCQ 141 Mark
What is the use of tell() method in Python?
  • returns the current position of record pointer within the file
  • B
    returns the end position of record pointer within the file
  • C
    returns the current position of record pointer within the line
  • D
    none of the above
Answer
Correct option: A.
returns the current position of record pointer within the file
returns the current position of record pointer within the file
View full question & answer
MCQ 151 Mark
The readlines() returns
  • A
    only first line from the file
  • B
    only last line from the file
  • all lines from the file
  • D
    none of the above
Answer
Correct option: C.
all lines from the file
all lines from the file
View full question & answer
MCQ 161 Mark
To read the content of the file as a string via a file object "f"
  • f.read
  • B
    f.read
  • C
    f=file.readline()
  • D
    f.readlines()
Answer
Correct option: A.
f.read
f.read
View full question & answer
MCQ 171 Mark
To read two characters from a file object "file_read"
  • file_read.read(2)
  • B
    file_read(2)
  • C
    file_read(read,2)
  • D
    file_read.readlines(2)
Answer
Correct option: A.
file_read.read(2)
file_read.read(2)
View full question & answer
MCQ 181 Mark
To open a file "c:marks.txt" for reading, we use
  • file_read = open("c:marks.txt", "r")
  • B
    file_read = open("c:marks.txt", "r")
  • C
    file_read = open(file = "c:marks.txt", "r")
  • D
    file_read = open(file = "c:marks.txt", "r")
Answer
Correct option: A.
file_read = open("c:marks.txt", "r")
file_read = open("c:marks.txt", "r")
View full question & answer
MCQ 191 Mark
The modes of file in python are
  • A
     r
  • B
    $\mathrm{r}^{+}$
  • C
  • All of the these
Answer
Correct option: D.
All of the these
All of the these
View full question & answer
M.C.Q - Computer Science STD 12 Humanities Questions - Vidyadip