कौन सा कथन एक फ़ाइल (फ़ाइल ऑब्जेक्ट „f‟) से 5 अक्षर पढ़ेगा?
Which statement will read 5 characters from a file(file object „f‟) ?
A)
B)
C)
D)
Explanation:
The correct answer is:
(B) f.read(5)
Explanation:
f.read(5)
reads exactly 5 characters from the file. The number5
specifies 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 noreads
method.
Output:
(B) f.read(5)