google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Write a Program to Implement Dictionary in Python

Write a Program to Implement Dictionary in Python

0

 


 

#Write a Program to Implement Dictionary in Python

# empty dictionary
my_dict {}
print(my_dict)

# dictionary with integer keys
my_dict {1'apple'2'ball'}
print(my_dict)

# dictionary with mixed keys
my_dict {'name''John'1[243]}
print(my_dict)

# using dict()
my_dict dict({1:'apple'2:'ball'})
print(my_dict)

# from sequence having each item as a pair
my_dict dict([(1,'apple'), (2,'ball')])
print(my_dict)

Output:

{}

{1: 'apple', 2: 'ball'}

{'name': 'John', 1: [2, 4, 3]}

{1: 'apple', 2: 'ball'}

{1: 'apple', 2: 'ball'}

 

 


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top