Which statement will read 5 characters from a file(file object ‘f’)?
1.f.read()
2.f.read(5)
3.f.reads(5)
4.None of the above
A _____ file consists of human readable characters.
1.Binary
2. Text
3.Both of the above
4.None of the above
Almost all the files in our computer stored as _______ File
1.Text
2.Binary
3.CSV
4.None of the above
Fill in the blank import pickle f=open("data.dat",'rb') d=_____________________.load(f) f.close()
1.unpickle
2.pickling
3.pickle
4. pick
open( ) function takes ____ as parameter.
1.File name
2.Access mode
3.Both of the above
4.None of the above
Ravi opened the file myfile.txt in append mode. In this file the file object/file handle will be at the ___
1.beginning of the file
2.end of the file
3. second line of the file
4.the end of the first line
Refer to the above code (Q 47) : Write the output of Third Print Statement
1.e to m
2.e to my
3.to my
4. None of the above
The syntax of seek() is: file_object.seek(offset [, reference_point]) What is reference_point indicate?
1. reference_point indicates the starting position of the file object
2.reference_point indicates the ending position of the file object
3.reference_point indicates the current position of the file object
4.None of the above
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.second line of the file
Which function is used to write data in binary mode?
1.write
2.writelines
3.pickle
4.dump
Which of the following is an invalid mode of file opening?
1.read only mode
2. write only mode
3.read and write mode
4.write and append mode
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â€)
Write the output of the following: >>> f = open("test.txt","w") >>> f.close() >>> f.closed
1.True
2.False
3.yes
4.No
A _____________ is a named location on a secondary storage media where data are permanently stored for later access
1. file
2.variable
3.comment
4.token
Default EOL character in text file is _____
1.
2. N
3.
4. l
Each line of a text file is terminated by a special character, called the ____
1.End of File
2.End of Line
3.End of Statement
4. End of program
EOF stands for ___________
1. End of File
2.End off File
3.End on File
4.End or Fil
f.seek(10,0) will move 10 bytes forward from beginning of file.
1.True
2.False
3.yes
4.Error
File in python is treated as sequence of ________________
1.Bytes
2.Bites
3.bits
4.None of the above
Fill in the blanks in the following code of writing data in binary files. Choose the answer for statement 1 import ___________ # Statement 1 rec = [ ] while True: rn = int(input("Enter")) nm = input("Enter") temp = [rn, nm] rec.append(temp) ch = input("Enter choice (Y/N)") if ch.upper == "N": break f = open("stud.dat", "____________") #statement 2 __________ .dump(rec, f) #statement 3 _______.close( ) # statement 4
1.csv
2.unpickle
3.pickle
4.load
Identify the correct statement to open a file:
1.f = open(“D:\myfolder\naman.txtâ€)
2.f = open(“D:myfolder aman.txtâ€)
3. f = open(“D:myfolder#naman.txtâ€)
4.f = Open(“D:myfolder aman.txtâ€)
Identify the invalid mode from the following.
1. a
2.. r+
3.ar+
4.w
In the given statement, the file myfile.txt will open in _______________ mode. myObject=open(“myfile.txtâ€, “a+â€)
1.append and read
2.append and write
3.append and read and binary
4.All the above
In which of the following data store permanently?
1.File
2.Variable
3.Both of the above
4.None of the above
Let the file pointer is at the end of 3rd line in a text file named “data.txtâ€. Which of the following option can be used to read all the remaining lines?
1.f.read( )
2.f.read(all)
3.f.readline( )
4.f.readlines( )
open( ) function returns a file object called _____
1.object handle
2. file handle
3.read handle
4.write handle
pdf and .doc are examples of __________ files.
1.Text
2.Binary
3.CSV
4.None of the above
Ram opened a file in a certain mode. After opening the file, he forgot the mode. The interesting facts about that mode are †If the file doesn’t exist, then a new file will be created†and “After opening file in that mode the file handle will be at the end of the file†Help him to identify the correct mode.
1.read mode
2.write mode
3.append mode
4. binary and read mode
Ravi opened a file in a certain mode. After opening the file, he forgot the mode. One interesting fact about that mode is †If the file already exists, all the contents will be overwrittenâ€. Help him to identify the correct mode.
1.read mode
2.write mode
3.append mode
4.binary and read mode
Ravi opened a file in python using open( ) function but forgot to specify the mode. In which mode the file will open?
1.write
2.append
3.read
4.read and write both
Ravi opened the file myfile.txt in write mode. In this file the file object/file handle will be at the __
1.beginning of the file
2.end of the file
3.second line of the file
4.the end of the first line
readlines( ) function returns all the words of the file in the form of List. (T/F)
1.True
2.False
3.yes
4.Error
readlines() method return _________
1.String
2.List
3.Dictionary
4.Tuple
Refer to the above code (Q 38)and choose the option for statement 3
1.unpickle
2.write
3.pickle
4.None of the above
Refer to the above code (Q 38)and choose the option for statement 4.
1.f
2.rec
3.file
4.stud
Refer to the above code (Q 47) : Write the output of Fourth Print Statement
1.17
2.16
3.19
4.18
Refer to the above code (Q 47) : Write the output of Second Print Statement
1.om
2.me
3.co
4.None of the above
Refer to the above code and choose the option for statement2.
1.w
2.w+
3.wb
4.write
The syntax of seek() is:file_object.seek(offset [, reference_point] What is the default value of reference_point
1.0
2.1
3.2
4.3
The syntax of seek() is:file_object.seek(offset [, reference_point]) What all values can be given as a reference point?
1.1
2.2
3.0
4.All of the above
What error is returned by the following statement if the file does not exist? f=open("A.txt")
1.FileNotFoundError
2. NotFoundError
3.NotFoundError
4.FoundError
What is ‘f’ in the following statement? f=open("Data.txt" , "r")
1. File Name
2.File Handle
3.Mode of file
4.File Handling
What is full form of CSV
1.Comma Separation Value
2.Comma Separated Value
3.Common Syntax Value
4.Comma Separated Variable
When we open file in write mode the file pointer is at the _______ of the file.
1.end
2.beginning
3.anywhere in between the file
4.second line of the file
Which function is used to force transfer of data from buffer to file?
1. flush( )
2.save( )
3.move( )
4.None of the above
Which function is used to read data from Text File?
1.a. read( )
2.writelines( )
3.pickle( )
4.dump( )
Which function open file in python?
1.open( )
2.new( )
3.Open( )
4.None of the above
Which mode create new file if the file does not exist?
1.write mode
2.append mode
3.Both of the above
4.None of the above
Which module to be imported to make the following line functional? sys.stdout.write("ABC")
1.system
2.sys
3.stdout
4.stdin
Which of the following are the attributes of file handle?
1.closed
2.name
3.mode
4.All the above
Which of the following attribute of file handle returns Boolean value?
1.name
2.closed
3.mode
4.None of the above
Which of the following error is returned when we try to open a file in write mode which does not exist?
1.FileNotFoundError
2.FileFoundError
3.FileNotExistError
4.None of the above
Which of the following file can be created in python?
1.Text File
2. Binary File
3.CSV File
4.All the above
Which of the following file can be opened in any text editor?
1. Binary
2.Text
3.Both of the above
4.None of the above
Which of the following file require specific programs to access its contents?
1.Binary
2.Text
3.CSV
4.None of the above
Which of the following function is used to close the file?
1. close( )
2.end( )
3.quit( )
4.exit( )
Which of the following function takes two arguments?
1. load( )
2.dump( )
3.Both of the above
4.None of the above
Which of the following is invalid mode of opening file?
1.r
2.rb
3.+r
4.None of the above
Which of the following is the valid way to open the file?
1. with open (file_name, access_mode) as fo:
2.fo = open (file_name, access_mode)
3.Both of the above
4.None of the above
Which of the following mode will create a new file, if the file does not exist?
1. ‘a’
2.‘a+
3. ‘+a’
4.All the above
Which of the following mode will open the file in binary and read-only mode.
1. ‘r’
2. ‘rb’
3.‘r+’
4. ‘rb+’
Which of the following mode will opens the file in read, write and binary mode?
1.‘wb+
2.‘+wb’
3.Both of the above
4.None of the above
Which of the following options can be used to read the first line of a text file data.txt?
1.f = open(‘data.txt’); f.read()
2. f = open(‘data.txt’,’r’); f.read(n)
3.myfile = open(‘data.txt’); f.readline()
4. f = open(‘data.txt’); f.readlines()
Which of the following will read entire content of file(file object ‘f’)?
1. f.reads( )
2.f.read( )
3.f.read(all)
4.f.read( * )
Which statement will move file pointer 10 bytes backward from current position.
1.Which statement will move file pointer 10 bytes backward from current position. a. f.seek(-10, 0)
2.f.seek(10, 0)
3. f.seek(-10, 1)
4.None of the above
Which statement will return error? import pickle f=open("data.dat",'rb') d=pickle.load(f) f.end()
1.Statement 1
2.Statement 2
3.Statement 3
4. Statement 4
Which statement will return one line from a file (file object is ‘f’)?
1. f.readline( )
2.f.readlines( )
3.f.read( )
4. f.line( )
Which symbol is used for append mode?
1. ap
2.a
3.w
4.app
Write the output of the First Print statements : f=open("data.txt",'w') f.write("Hello") f.write("Welcome to my Blog") f.close() f=open("data.txt",'r') d=f.read(5) print(d) # First Print Statement f.seek(10) d=f.read(3) print(d) # Second Print Statement f.seek(13) d=f.read(5) print(d) # Third Print Statement d=f.tell() print(d) # Fourth Print Statement
1.Hello
2.Hell
3.ello
4.None of the above
Write the output of the following: >>> f = open("test.txt","w") >>> f.closed
1.True
2.False
3.yes
4.Error
Write the output of the following: >>> f = open("test.txt","w") >>> f.mode
1.‘w’
2.‘r’
3. ‘a’
4.w+’
Write the output of the following: >>> f = open("test.txt","w") >>> f.name
1.‘test’
2. ‘test.txt’
3.test.dat’
4.file does not exist
_______ function returns the current position of file pointer. a.
1.get( )
2. tell( )
3. cur( )
4. seek( )
_____________ function returns the strings
1.read( )
2.readline( )
3.Both of the above
4.None of the above
__________________ module is used for serializing and de-serializing any Python object structure.
1.pickle
2.unpickle
3.pandas
4.math