dict():-
dict() function का used dictionary को create करने के लिए किया जाता है।
dict1 = dict({“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’})
print(dict1) # {“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
len():-
len() function का used dictionary की length का पता करने के लिए किया जाता है।
dict = {“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
print(len(dict)) # 3
clear():-
clear() method का used dictionary को clear करने के लिए किया जाता है।
dict={“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
dict.clear()
print(dict) # {}
copy():-
copy() method का used Dictionary को copy करने के लिए किया जाता है।
dict1 = {“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
dict2 = dict1.copy()
print(dict1) # {‘one’: ‘Ramesh’, ‘two’: ‘suresh’, ‘three’: ‘rajesh’}
print(dict2) # {‘one’: ‘Ramesh’, ‘two’: ‘suresh’, ‘three’: ‘rajesh’}
Dict():-
dict() function is used to create a dictionary.
dict1 = dict({“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’})
print(dict1) # {“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
len():-
The len() function is used to find the length of the dictionary.
dict = {“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
print(len(dict)) # 3
clear():-
clear() method is used to clear the dictionary.
dict={“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
dict.clear()
print(dict) # {}
copy():-
copy() method is used to copy the dictionary.
dict1 = {“one”:’Ramesh’, “two”:’suresh’, “three”:’rajesh’}
dict2 = dict1.copy()
print(dict1) # {‘one’: ‘Ramesh’, ‘two’: ‘suresh’, ‘three’: ‘rajesh’}
print(dict2) # {‘one’: ‘Ramesh’, ‘two’: ‘suresh’, ‘three’: ‘rajesh’}