Computer Science, asked by diptisingh, 9 months ago

what are the kind of key value pair in python​

Answers

Answered by cuterambo
0
in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair.

While using Dictionary, sometimes, we need to add or modify the key/value inside the dictionary. Let’s see how to add a key:value pair to dictionary in Python.

Code #1: Using Subscript notation

This method will create a new key:value pair on a dictionary by assigning a value to that key.

# Python program to add a key:value pair to dictionary



dict = {'key1':'geeks', 'key2':'for'}

print("Current Dict is: ", dict)


# using the subscript notation
# Dictionary_Name[New_Key_Name] = New_Key_Value



dict['key3'] = 'Geeks'

dict['key4'] = 'is'

dict['key5'] = 'portal'

dict['key6'] = 'Computer'

print("Updated Dict is: ", dict)
Answered by sukamisureki46
0

Answer:

patron is an unorded collection of data value to stored data value like map.

which unlike other data type that hold only single value as element, dictionary hold key.

code#1= using subscript potation

it used for creating new key.

code#2=using update ( ) methods

code#3= taking key :value as input

Similar questions