Create Dictionary
Problem: Create a dictionary with keys as names and values as ages. Return the dictionary.
Input:
names= ["Amit","Riya"]
ages= [25,30]
Output:
{"Amit":25,"Riya":30}
Access Value
Problem: Return value of given key from dictionary.
Input:
d= {"a":10,"b":20}
key="b"
Output:
20
Check Key Exists
Problem: Return true if key exists in dictionary.
Input:
d= {"x":1,"y":2}
key="x"
Output:
true
Count Keys
Problem: Return total number of keys in dictionary.
Input:
d= {"a":1,"b":2,"c":3}
Output:
3
Sum of Values
Problem: Return sum of all dictionary values.
Input:
d= {"a":10,"b":20,"c":30}
Output:
60
Update Value
Problem: Update value of a given key.
Input:
d= {"a":10}
key="a"
new_value=50
Output:
{"a":50}
Delete Key
Problem: Remove a key from dictionary.