Wednesday, August 19, 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

SynthID and C2PA Explained

Welcome to another AI-focused article here on datasagar.com! As I scroll through my social media feeds lately, I find myself playing a...

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

Most Popular

SynthID and C2PA Explained

Welcome to another AI-focused article here on datasagar.com! As I scroll through my social media feeds lately, I find myself playing a...

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

What is Answer Engine Optimization (AEO)? Getting Ready for AI Powered Search and Agentic Era Digital Marketing

Search is changing faster than it has in the last two decades. For years, businesses focused on ranking their websites on search...