Question 1 of 25
Hints left: 3
Q1
How do you delete a file?
Q2
What will be the output of the following Python code? str = input("Enter your input: "); print "Received input is : ", str
-
A
-
B
-
C
-
D
Q3
To read the remaining lines of the file from a file object infile, we use . . . . . . . .
Q4
What will be the output of the following Python code? import sys sys.stdout.write(' Hello\n') sys.stdout.write('Python\n')
Q5
To read the next line of the file from a file object infile, we use . . . . . . . .
Q6
Which of the following is not a valid attribute of a file object (fp)?
Q7
How do you change the file position to an offset value from the start?
Q8
How can you open a file for both reading and writing in Python?
Q9
How can you rename a file in Python?
Q10
How do you close a file object (fp)?
Q11
How do you rename a file?
Q13
What is the difference between r+ and w+ modes?
Q14
How do you get the current position within the file?
Q15
What is the purpose of the truncate() method in file handling?
Q16
What is the purpose of the a mode when opening a file in Python?
Q17
How can you remove a file in Python?
Q18
The readlines() method returns . . . . . . . .
Q19
What is the pickling?
Q20
How can you read the entire contents of a binary file in Python?
Q21
What is the output of the following code: with open('data.txt', 'r') as file: lines = file.readlines() print(len(lines))
Q22
Which function is used to close a file in python?
Q23
What is the output of the following code: with open('data.txt', 'r') as file: content = file.read(10) print(content)
Q24
What is the use of seek() method in files?
Q25
What is the use of truncate() method in file?