Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : 'r+' / 'r+'

Advertisement

Detailed Solution

सही उत्तर 'r+' / 'r+' है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Which Python file mode opens a file for both reading and writing, positions the stream at the beginning, and does NOT truncate the existing contents? / Python का कौन-सा फ़ाइल मोड फ़ाइल को पढ़ने और लिखने दोनों के लिए खोलता है, स्ट्रीम को शुरुआत में रखता है और मौजूदा सामग्री को ट्रंकेट नहीं करता?

1.
'w+' — truncates the file first / फ़ाइल को पहले ट्रंकेट करता है
2.
'r+' / 'r+'
3.
'x+' — fails if the file already exists / फ़ाइल पहले से मौजूद हो तो विफल हो जाता है
4.
'a+' — positions the stream at the end for writing / लिखने के लिए स्ट्रीम को अंत में रखता है

Correct Answer: 'r+' / 'r+'

'r+' opens for reading and writing without truncating; 'w+' truncates, 'x+' requires the file not to exist, and 'a+' writes at the end. / 'r+' बिना ट्रंकेट किए पढ़ने-लिखने के लिए खोलता है; 'w+' ट्रंकेट करता है, 'x+' में फ़ाइल का न होना ज़रूरी है और 'a+' अंत में लिखता है।

Downloaded from PrepSnap (prepsnap.in)