Problem Solving And Python Programming Set 16
On This Page
This set of Problem Solving and Python Programming Multiple Choice Questions & Answers (MCQs) focuses on Problem Solving And Python Programming Set 16
Q1 | Which of the following statements are true?
- when you open a file for reading, if the file does not exist, an error occurs
- when you open a file for writing, if the file does not exist, a new file is created
- when you open a file for writing, if the file exists, the existing file is overwritten with the new file
- all of the mentioned
Q2 | 1 TEXT FILES, READING AND WRITING FILES, FORMAT OPERATOR
- infile.read(2)
- infile.read()
- infile.readline()
- infile.readlines()
Q3 | To read the remaining lines of the file from a file object infile, we use
- infile.read(2)
- infile.read()
- infile.readline()
- infile.readlines()
Q4 | print(f.closed)
- true
- false
- none
- error
Q5 | Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
- raw_input & input
- input & scan
- scan & scanner
- scanner
Q6 | Which one of the following is not attributes of file?
- closed
- softspace
- rename
- mode
Q7 | What is the use of tell() method in python?
- tells you the current position within the file
- tells you the end position within the file
- tells you the file is opened or not
- none of the mentioned
Q8 | What is the current syntax of rename() a file?
- rename(current_file_name, new_file_name)
- rename(new_file_name, current_file_name,)
- rename(()(current_file_name, new_file_name))
- none of the mentioned
Q9 | What is the current syntax of remove() a file?
- remove(file_name)
- remove(new_file_name, current_file_name,)
- remove(() , file_name))
- none of the mentioned
Q10 | fo.close()
- compilation error
- syntax error
- displays output
- none of the mentioned
Q11 | What is the use of seek() method in files?
- sets the file’s current position at the offset
- sets the file’s previous position at the offset
- sets the file’s current position within the file
- none of the mentioned
Q12 | What is the use of truncate() method in file?
- truncates the file size
- deletes the content of the file
- deletes the file size
- none of the mentioned
Q13 | Which is/are the basic I/O connections in file?
- standard input
- standard output
- standard errors
- all of the mentioned
Q14 | print 'Your name is:', name
- sanfoundry
- sanfoundry, sanfoundry
- san
- none of the mentioned
Q15 | sys.stdout.write('Python\n')
- compilation error
- runtime error
- hello python d)
- hello python
Q16 | Which of the following mode will refer to binary data?
- r
- w
- +
- b
Q17 | What is the pickling?
- it is used for object serialization
- it is used for object deserialization
- none of the mentioned
- all of the mentioned
Q18 | What is unpickling?
- it is used for object serialization
- it is used for object deserialization
- none of the mentioned
- all of the mentioned
Q19 | What is the correct syntax of open() function?
- file = open(file_name [, access_mode][, buffering])
- file object = open(file_name [, access_mode][, buffering])
- file object = open(file_name)
- none of the mentioned
Q20 | fo.close()
- compilation error
- runtime error
- no output
- flushes the file when closing them
Q21 | Correct syntax of file.writelines() is?
- file.writelines(sequence)
- fileobject.writelines()
- fileobject.writelines(sequence)
- none of the mentioned
Q22 | Correct syntax of file.readlines() is?
- fileobject.readlines( sizehint );
- fileobject.readlines();
- fileobject.readlines(sequence)
- none of the mentioned
Q23 | In file handling, what does this terms means “r, a”?
- read, append
- append, read
- write, append
- none of the mentioned
Q24 | What is the use of “w” in file handling?
- read
- write
- append
- none of the mentioned
Q25 | What is the use of “a” in file handling?
- read
- write
- append
- none of the mentioned