Important Notice:

Course Content
Dictionary in Python (Chapter-9) M3-R5
About Lesson

zip():-

                दो लिस्ट को as a key and value में represent करने के लिए zip() method का use किया जाता है

reg=[1491514,1491515,1491516]

name=[‘ankit’,’sunil’,’mahesh’]

st=dict(zip(reg,name))

print(st)                           # {1491514: ‘ankit’, 1491515: ‘sunil’, 1491516: ‘mahesh’}

has_key():-

                has_key() method का इस्तेमाल दी हुई key; dictionary पर है या नहीं ये boolean value में return किया जाता है यदि has_key() method में दी हुई key; dictionary में होती है तो ‘True’ return होता है और अगर नहीं होती है तो ‘False’ return होता है

Note:- has_key() method; Python 3.x versions पर support नहीं करता है

sorted():-

                दिए गए dictionary को sort करके उसकी key को list के रूप में return करता है

dict1 = { ‘num6’: 6, ‘num3’: 3, ‘num2’: 2, ‘num4’: 4, ‘num1’: 1, ‘num5’: 5}

sortedDict = sorted(dict1)

print(sortedDict)                      # [‘num1’, ‘num2’, ‘num3’, ‘num4’, ‘num5’, ‘num6’]

Min & max:-

Sum:

Concatenation & repletion is not support in dict

Comparison operation (<,  >,<=, >=) is work

 

 

zip():-

                zip() method is used to represent two lists as a key and value.

reg=[1491514,1491515,1491516]

name=[‘ankit’,’sunil’,’mahesh’]

st=dict(zip(reg,name))

print(st)                             # {1491514: ‘ankit’, 1491515: ‘sunil’, 1491516: ‘mahesh’}

has_key():-

                The given key is used using the has_key() method; Whether it is on the dictionary or not is returned as a boolean value if the key given in the has_key() method; If it is in the dictionary then ‘True’ is returned and if it is not then ‘False’ is returned.

Note:- has_key() method; Does not support Python 3.x versions

sorted():-

Sorts the given dictionary and returns its keys.

dict1 = { ‘num6’: 6, ‘num3’: 3, ‘num2’: 2, ‘num4’: 4, ‘num1’: 1, ‘num5’: 5}

sortedDict = sorted(dict1)

print(sortedDict)                  #[‘num1’, ‘num2’, ‘num3’, ‘num4’, ‘num5’, ‘num6’]

error: Content is protected !!