File opening in various modes

Qus. 1 : If we open a file in write mode and file does not exists, which of the error will generate?

  1. File Found Error
  2. File Not Exist Error
  3. File Not Found Error
  4. None of these
Qus. 2 : Which of the following is an invalid mode?

  1. a
  2. ar+
  3. r+
  4. w
Qus. 3 : Which of the following is not a correct mode to open a file ?

  1. ab
  2. rw
  3. a+
  4. r+
Qus. 4 : Which of the following error is returned when we try to open a file in write mode which does not exist?

  1. File Found Error
  2. File Not Exist Error
  3. File Not Found Error
  4. None of the above
Qus. 5 : Which statement will return one line from a file (file object is f) ?

  1. f.readlines()
  2. f.readline()
  3. f.read()
  4. f.line()
Qus. 6 : In which format Binary file contains information?

  1. Quick response code
  2. Same format in which the data is held in memory
  3. ASCII format
  4. Unicode format
Qus. 7 : Which of the following mode argument is used in file to truncate ?

  1. a
  2. f
  3. w
  4. t
Qus. 8 : Which statement will open file "data.txt" in append mode?

  1. f = open("data.txt", "a")
  2. f = Open("data.txt", "ab")
  3. f= new("data.txt", "a")
  4. open("data.txt", "a")
Qus. 9 : When we open file in append mode the file pointer is at the ______ of the file.

  1. end
  2. beginning
  3. anywhere in between the file
  4. None of the above
Qus. 10 : Which of the following functions is used to open a file in Python?

  1. open_file()
  2. file_open()
  3. open()
  4. read_file()
Qus. 11 : How can you close a file in Python after processing?

  1. close_file()
  2. file_close()
  3. close()
  4. end_file()
Qus. 12 : which is a correct way to open a file in python

  1. file_object=open(file_name,mode)
  2. open(file_object,file_name,mode)
  3. file_open(file_object,file_name,mode)
  4. file_object=file_open(file_name,mode)
Qus. 13 : Which of the following is not a valid mode to open a file?

  1. ab
  2. rw
  3. r+
  4. w+
Qus. 14 : What is the default mode for files in Python?

  1. Write
  2. Read
  3. Append
  4. Read and Write Both

Programs

python program to read the full content of specified txt file

View Solution


python program to accept file name and data from user and write data on file

View Solution


python program to count the number of lines in the file

View Solution


python program to display the size of a file in byte

View Solution


python program to display all the records in a file along with line number

View Solution


python program to display only last line of a text file

View Solution


python program that reads a text file and creates another file that is identical except that every sequence of consecutive blank spaces is replaced by single space

View Solution


python program to create a function that would read contents from the sports.dat and creates a file named Atheletic.dat

View Solution


python program to read csv file content line by line

View Solution


Write Python code to display sentence starting with given character from abc.txt file

View Solution


Python code to display digits from abc.txt file

View Solution


python program to copy the one contents to another

View Solution


python program to copy the all word which start with constant in another file

View Solution


python program to add delete and display all record of binary file

View Solution


python program to read data from csv file

View Solution


Python program to write data on csv file

View Solution


python program to write first n prime number in text file

View Solution


python program to marge the content of target file into source file

View Solution


python program to read txt file data from specified index to specified length

View Solution


python program to delete the specified file from computer

View Solution


Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad