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