ExamVeda
Login
Home
41
What does the w mode indicate when opening a file in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
42
Which of the following is not a valid mode to open a file?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
43
How can you copy the contents of one file to another in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
44
Which one of the following is not attributes of file?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
45
What is the use of "w" in file handling?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
46
What will be the output of the following Python code?
str = raw_input("Enter your input: ");
print "Received input is : ", str
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
47
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()
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
48
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)
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
49
How do you rename a file?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
50
How can you read the entire contents of a binary file in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board