Question 1 of 25
Hints left: 3
Q1
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)
Q2
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()
Q3
Which function is used to read single line from file?
Q4
Which one of the following is not attributes of file?
Q5
Which function is used to read all the characters?
Q6
What is the current syntax of remove() a file?
Q7
How can you check the current position in a file in Python?
Q8
How can you copy the contents of one file to another in Python?
Q9
What happens if no arguments are passed to the seek function?
Q10
Correct syntax of file.readlines() is?
Q11
What is the use of tell() method in python?
Q12
What will be the output of the following Python code? str = raw_input("Enter your input: "); print "Received input is : ", str
Q13
Which function is used to write a list of string in a file?
Q14
To read the entire remaining contents of the file as a string from a file object infile, we use . . . . . . . .
Q15
Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
Q16
Which function is used to write all the characters?
Q17
Which of the following mode will refer to binary data?
Q18
How can you check if a file exists in Python before opening it?
Q19
Which of the following is not a valid mode to open a file?
Q20
Which of the following are the modes of both writing and reading in binary format in file?
Q21
In file handling, what does this terms means "r, a"?
Q22
How do you get the name of a file from a file object (fp)?
Q23
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
Q24
What is the use of "w" in file handling?
Q25
What does the w mode indicate when opening a file in Python?