Wednesday, September 30, 2026
Home Academic Creating dictionary in Python

Creating dictionary in Python

A Dictionary is an unordered set of key:value pairs, with the requirement that the keys are unique (within a Dictionary). A few pointers about dictionary:

  • An empty dictionary can be created by a pair of braces: {}.
  • Dictionary elements can be accessed by dictionary keys
  • DICT.keys() will return all the keys of given dictionary “DICT”

DICT = {
'Name':'Kunal',
'Company':'Analytics Vidhya'
}

#Dictionary elements can be accessed by keys

print (DICT['Name'])

#The above print statement will print Kunal

In dictionary “DICT”, Name and Company are dictionary keys whereas “Kunal” and “Analytics Vidhya” are their respective values.

Other Tasks:

# Create a dictionary dict1
dict1 = { ‘Age’: 16, ‘Name’: ‘Max’, ‘Sports’: ‘Cricket’}

# Update the value of Age to 18
dict1[‘Age’] = 18

# Print the value of Age
print(dict1[‘Age’])

# Store the keys of dictionary dict1 to dict_keys
dict_keys = dict1.keys()

Try it yourself in DataCamp here

datasagarhttp://www.DataSagar.com
Sagar is multidisciplinary technologist, educator, and entrepreneur based in Nepal. As the founder of Illionso Technologies and Kashi Garden Resort, he operates at the intersection of web architecture, data intelligence, innovation, and digital transformation. From building digital solutions to scaling real-world concepts, his mission is to share knowledge alongside merge emerging as well as disruptive technologies with transformative offline experiences.
RELATED ARTICLES

Meta Muse AI Agent Everything You Need to Know About Features and Privacy

Discover everything about Meta Muse, the new personal AI agent designed to execute goals 24/7. Explore its features, Secure Virtual Machine privacy, token pricing, and the future of autonomous AI.

Nepal Government Approves Software Development Center to Hire 93 IT Specialists – Gov Tech Updates

Nepal is taking a massive step forward in government technology. The administration has formally advanced plans...

Most Popular