कौन सा कथन एक फ़ाइल (फ़ाइल ऑब्जेक्ट „f‟) से 5 अक्षर पढ़ेगा?
Which statement will read 5 characters from a file(file object „f‟) ?
A
f.read()
B
f.read(5)
C
f.reads(5)
D
None of the above
Explanation
The correct answer is:
(B) f.read(5)
Explanation:
f.read(5)reads exactly 5 characters from the file. The number5specifies the number of characters to read from the file.f.read()without a number will read the entire file or until the end of the file.f.reads(5)is incorrect and will raise an error since there is noreadsmethod.
Output:
(B) f.read(5)
Correct Answer: B) f.read(5)