Question 1 of 25
Hints left: 3
Q1
Which function is used to read single line from file?
Q2
Which of the following are the modes of both writing and reading in binary format in file?
Q3
What is the use of tell() method in python?
Q4
In file handling, what does this terms means "r, a"?
Q5
To read the entire remaining contents of the file as a string from a file object infile, we use . . . . . . . .
Q6
What is the use of "w" in file handling?
Q7
How can you check the current position in a file in Python?
Q8
Which function is used to write all the characters?
Q9
Which function is used to read all the characters?
Q10
How can you copy the contents of one file to another in Python?
Q11
Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
Q12
What will be the output of the following Python code? str = raw_input("Enter your input: "); print "Received input is : ", str
Q13
What will be the output of the following Python code? fo = open("foo.txt", "rw+") print "Name of the file: ", fo.name # Assuming file has following 5 lines # This is 1st line # This is 2nd line # This is 3rd line # This is 4th line # This is 5th line for index in range(5): line = fo.next() print "Line No %d - %s" % (index, line) # Close opened file fo.close()
Q14
Which one of the following is not attributes of file?
Q15
What does the w mode indicate when opening a file in Python?
Q16
Which of the following mode will refer to binary data?
Q17
What happens if no arguments are passed to the seek function?
Q18
How can you check if a file exists in Python before opening it?
Q19
Correct syntax of file.readlines() is?
Q20
How do you get the name of a file from a file object (fp)?
Q21
What will be the output of the following Python code? (If entered name is examveda) import sys print 'Enter your name: ', name = '' while True: c = sys.stdin.read(1) if c == '\n': break name = name + c print 'Your name is:', name
Q22
What will be the output of the following Python code? f = None for i in range (5): with open("data.txt", "w") as f: if i > 2: break print(f.closed)
Q23
Which function is used to write a list of string in a file?
Q24
What is the current syntax of remove() a file?
Q25
Which of the following is not a valid mode to open a file?