MCQ Answer

Which is the function to read the remaining lines of the file from a file object infile?

Which is the function to read the remaining lines of the file from a file object infile?

फ़ाइल ऑब्जेक्ट infile से फ़ाइल की शेष पंक्तियों को पढ़ने के लिए कौन सा फंक्शन है?
Topic : File Processing in Python

A. infile.read(2)

B. infile.read()

C. infile.readlines()

D. infile.readline()




Correct Answer is :

C. infile.readlines()



Explanation

In Python, to read the remaining lines of a file from a file object (infile), you can use the readlines() method. The readlines() method reads all the lines of a file and returns a list where each element of the list is a line from the file. If you have already read some lines from the file using methods like readline() or read(), calling readlines() will continue reading the remaining lines.

# Open the file in read mode
with open('your_file.txt', 'r') as infile:
    # Read the remaining lines using readlines()
    remaining_lines = infile.readlines()
# Now, remaining_lines is a list containing all the lines in the file
print(remaining_lines)


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz