Python Tutorial for beginners_Basic Dict operations_Tutorial 4
#Python#Dict#programming#tamil #Simple Dict sd = { 'Name':'Sathish', 'Age': 26, 'Country':'India' } print('Dict value is:', sd) # Updating the Value of Name Key sd['Name'] = 'New name' print('Updated Dict value is:',sd) # Inserting the new key value Pair sd['pincode'] = 637207 print('New Dict is:',sd) # printing Keys from the dict keys = sd.keys() print('The Keys are:',keys) # printing values from the dict values = sd.values() print('The Keys are:',values) #printing the items from the dict dict_values = sd.items() print('The Keys are:',dict_values) # removing the last item from the list remove_last_item = sd.popitem() print('Popitem is:',remove_last_item) print('After popitem the dict value is:',sd) #removing the key&value pair from dict remove_keyvalue_pair = sd.pop('Name') print('pop function removed:',remove_keyvalue_pair) print('After removing the key and value pair',sd) # Dict with list values new_dict = { 'Name':['Sathish','Divakar','Sarath'], 'Age':[26,23,27], 'Country':'India' } #Accessing the values from the dict with list Value1 = new_dict['Name'][0] Value2 = new_dict['Age'][2] print('The required value from:',Value1,',',Value2)
#Python#Dict#programming#tamil #Simple Dict sd = { 'Name':'Sathish', 'Age': 26, 'Country':'India' } print('Dict value is:', sd) # Updating the Value of Name Key sd['Name'] = 'New name' print('Updated Dict value is:',sd) # Inserting the new key value Pair sd['pincode'] = 637207 print('New Dict is:',sd) # printing Keys from the dict keys = sd.keys() print('The Keys are:',keys) # printing values from the dict values = sd.values() print('The Keys are:',values) #printing the items from the dict dict_values = sd.items() print('The Keys are:',dict_values) # removing the last item from the list remove_last_item = sd.popitem() print('Popitem is:',remove_last_item) print('After popitem the dict value is:',sd) #removing the key&value pair from dict remove_keyvalue_pair = sd.pop('Name') print('pop function removed:',remove_keyvalue_pair) print('After removing the key and value pair',sd) # Dict with list values new_dict = { 'Name':['Sathish','Divakar','Sarath'], 'Age':[26,23,27], 'Country':'India' } #Accessing the values from the dict with list Value1 = new_dict['Name'][0] Value2 = new_dict['Age'][2] print('The required value from:',Value1,',',Value2)