निम्नलिखित में से कौन सी त्रुटि दिए गए कोड द्वारा लौटाई जाती है?
Which of the following error is returned by the given code ?
>>> f = open(“test.txt”,”w”)
>>> f.write(345)
A
Syntax Error
B
Type Error
C
String Error
D
Run Time Error
Explanation
In Python, the write() method expects a string as an argument, but 345 is an integer. Therefore, attempting to write an integer directly to a file will cause a TypeError.
Answer: (B) Type Error
Correct Answer: B) Type Error