Question
Option 4 : ABCXYZ / ABCXYZ
Detailed Solution
सही उत्तर ABCXYZ / ABCXYZ है।
Question:
A file "a.txt" contains `ABC`. What is the final content after this Python code? `f = open("a.txt", "r+")` / `data = f.read()` / `f.write("XYZ")` / `f.close()` / फ़ाइल "a.txt" में `ABC` है। इस Python कोड के बाद अंतिम content क्या होगा? `f = open("a.txt", "r+")` / `data = f.read()` / `f.write("XYZ")` / `f.close()`
Correct Answer: ABCXYZ / ABCXYZ
After `read()`, the file pointer sits at end-of-file (position 3), so `write("XYZ")` appends there, producing `ABCXYZ`. The trap option (c) assumes the pointer rewinds to the start before writing. / `read()` के बाद फ़ाइल पॉइंटर end-of-file (स्थिति 3) पर होता है, अतः `write("XYZ")` वहीं append करता है और `ABCXYZ` बनता है। जाल विकल्प (c) मानता है कि लिखने से पहले पॉइंटर शुरुआत में लौट आता है।