Professional Documents
Culture Documents
we use
2. Suppose there is a file named rome.txt, then the statement used to open a file for
writing, we use
3. Presume a file named rome.txt, then the statement used for appending data is
a. When you open a file for reading in ‘r’ mode, if the file does not exist, an error
occurs
b. When you open a file for writing in ‘w’ mode, if the file does not exist, a new
file is created
c. When you open a file for writing in ‘w’ mode, if the file exists, the existing file
for i in range(5):
if i > 0:
break
print(f.closed)
a. True
b. False
c. None
d. Error
a. CSV.DictWriter(filehandler)
b. CSV.reader(filehandler)
c. CSV.writer(filehandler)
d. CSV.write(filehandler)
a. ab
b. r+
c. w+
d. rw
a. str
b. a list of lines
d. a list of integers
11. Which of the following is not a valid attribute of the file object file_handler
a. file_handler.size
b. file_handler.name
c. file_handler.closed
d. file_handler.mode
a. closed
b. softspace
c. rename
d. mode
a. rename(current_file_name, new_file_name)
b. rename(new_file_name, current_file_name,)
c. rename(()(current_file_name, new_file_name))
a. remove(file_name)
b. (new_file_name, current_file_name,)
c. remove((), file_name))
a. leaf
b. stem
c. root
d. current directory
19. Which of the following are basic I/O connections in the file?
a. Standard Input
b. Standard Output
c. Standard errors
a. r
b. w
c. +
d. b
a. file name
b. file extension
c. file identifier
d. file variable
22. The method that returns the time of last modification of the file is
a. getmtime()
b. gettime()
c. time()
d. localtime()
a. object deserialization
b. object serialization
c. synchronization
file_handler = open("example.txt","x")
file_handler = open("moon.txt","r")
file_handler = open("C:\langur.txt","r")
file_handler = open("C:\prog\example.txt","r")
file_handler = open("C:\\fauna\\bison.txt","r")
file_handler = open("C:\\network\computer.txt","r")
file_handler = open(r"C:\network\computer.txt","r")
file_handler = open("titanic.txt","r")
f = open("ARCHIVO.txt", "w")
f.write("abcdefgh")
f.close()
import csv
def main():
csv_reader = csv.reader(csvfile)
print("Print each row in CSV file")
print(",".join(each_row))
if __name__ == "__main__":
main()