A text file song .txt contains the following contents in it:एक टेक्स्ट फाइल (text file ) song. txt में निम्नलिखित विषय-वस्तु निहित है:
A text file song .txt contains the following contents in it:
Life goes on as it never ends
What will be the output of the following code snippet?
f1 = open ("song.txt", "r")
s1 = f1. read (5)
s2 = f1. readline (4)
s3 = f1. read (3)
print (s1, s3, sep = "#")
एक टेक्स्ट फाइल (text file ) song. txt में निम्नलिखित विषय-वस्तु निहित है:
Life goes on as it never ends
निम्नलिखित कोड स्निपेट (Code snippet) का आउटपुट क्या होगा?
f1 = open ("song.txt", "r")
s1 = f1. read (5)
s2 = f1. readline (4)
s3 = f1. read (3)
print (s1, s3, sep = "#")
Show answerHide answer
Correct answer: (C) Life # onLife # on
Explanation
read(5) returns "Life ", readline(4) returns the next 4 characters "goes", and read(3) returns " on". Printing s1 and s3 with sep="#" gives "Life # on".read(5) "Life " लौटाता है, readline(4) अगले 4 अक्षर "goes" लौटाता है, और read(3) " on" लौटाता है। sep="#" के साथ s1 और s3 प्रिंट करने पर "Life # on" मिलता है।