🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड का आउटपुट क्या होगा?

What will be the output of the following code ?

f=open("demo.txt","w+")
f.write("Welcome to Python")
f.seek(5)
a=f.read(5)
print(a)
A)
B)
C)
D)

Explanation:

The code works as follows:

  1. The file "demo.txt" is opened in write and read mode (w+).
  2. The string "Welcome to Python" is written into the file.
  3. After writing, f.seek(5) moves the file pointer to position 5 (the sixth character, which is 'o' in the word "Welcome").
  4. f.read(5) reads the next 5 characters from the current position.

So, the output will be the next 5 characters starting from position 5, which is "me to".

Therefore, the correct answer is:

(B) me to

Latest Updates