Question 13Asked in Bihar STET 2025 Paper II Computer Science, 3 Nov 2025, Shift 1 (9:00 AM)

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 = "#")
  1. Agoes # ongoes # on
  2. BLife #goes # onLife #goes # on
  3. CLife # onLife # on
  4. DErrorError
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" मिलता है।

From Bihar STET 2025 Paper II Computer Science PYQ, 3 Nov 2025, Shift 1 (9:00 AM)

This is question 13 of Bihar STET 2025 Paper II Computer Science PYQ, 3 Nov 2025, Shift 1 (9:00 AM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.