Question
Option 1 : 1
Detailed Solution
सही उत्तर 1 है।
Question:
In the Python code below, three assignments target keys 1, 1.0 and True of the same dictionary. What number does it print? d = {1: 'a', 1.0: 'b', True: 'c'}; print(len(d)) / नीचे दिए गए Python कोड में एक ही डिक्शनरी की कुंजियों 1, 1.0 और True पर तीन असाइनमेंट किए गए हैं। वह कौन-सी संख्या प्रिंट करेगा? d = {1: 'a', 1.0: 'b', True: 'c'}; print(len(d))
Correct Answer: 1
In Python, 1, 1.0 and True are all equal (1 == 1.0 == True) and hash to the same value, so they are the same dictionary key; each assignment overwrites the previous one, leaving a single entry {1: 'c'}. / Python में 1, 1.0 और True सभी समान हैं (1 == 1.0 == True) और एक ही मान पर हैश होते हैं, अतः वे एक ही डिक्शनरी कुंजी हैं; प्रत्येक असाइनमेंट पिछले को अधिलेखित करता है, जिससे एकल प्रविष्टि {1: 'c'} बचती है।