Question

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

Option 1 : 'a'

Advertisement

Detailed Solution

सही उत्तर 'a' है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

In Python, which file mode opens a file for appending and creates the file if it does not exist? / Python में, कौन-सा फाइल मोड फाइल को जोड़ने (append) के लिए खोलता है और फाइल मौजूद न होने पर उसे बनाता है?

1.
'a'
2.
'r+'
3.
'w'
4.
'x'

Correct Answer: 'a'

Mode 'a' positions the stream at the end of the file and creates the file if absent. 'w' truncates existing content, 'r+' requires the file to exist, and 'x' fails if the file already exists. / मोड 'a' स्ट्रीम को फाइल के अंत में रखता है और फाइल न होने पर बनाता है। 'w' मौजूदा सामग्री को मिटा देता है, 'r+' के लिए फाइल का होना आवश्यक है, और 'x' फाइल पहले से मौजूद होने पर विफल होता है।

Downloaded from PrepSnap (prepsnap.in)