If the dictionary D1 is defined as: D1 = {1: 'a', 2: 'b'}यदि dictionary D1 को इस रूप में परिभाषित किया जाता है:
If the dictionary D1 is defined as:
D1 = {1: 'a', 2: 'b'}
then which of the following statements is incorrect and hence will result in an error?
यदि dictionary D1 को इस रूप में परिभाषित किया जाता है:
D1 = {1: 'a', 2: 'b'}
तो निम्नलिखित कथनों में से कौन-सा गलत कथन है और उसके परिणामस्वरूप एक error है?
Show answerHide answer
Correct answer: (C) D1 .del (1)D1 .del (1)
Explanation
Python dictionaries have no del method, so D1.del(1) is invalid. Deleting a key is done with the statement del D1[1]. D1.clear(1) would also fail, because clear() takes no arguments.Python dictionary में del मेथड नहीं होती, इसलिए D1.del(1) अमान्य है। key हटाने के लिए कथन del D1[1] है। D1.clear(1) भी विफल होता, क्योंकि clear() कोई आर्गुमेंट नहीं लेता।