Sunday, July 26, 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
The author of this blog post is a technology fellow, an IT entrepreneur, and Educator in Kathmandu Nepal. With his keen interest in Data Science and Business Intelligence, he writes on random topics occasionally in the DataSagar blog.
RELATED ARTICLES

How to setup DNS Records in Cloudflare – Guide for Website Owners

Whether you're launching your first website, connecting a custom email address, or moving your domain to a new hosting provider, you've probably...

DeepSeek AI: The Open-Source AI Disruptor Shaking Up the Tech World

DeepSeek AI is revolutionizing the artificial intelligence landscape with its open-source, cost-effective, and highly customizable model. Built on cutting-edge transformer architecture and fine-tuned using reinforcement learning with human feedback (RLHF), DeepSeek delivers human-like text generation and accurate responses. Its efficient training techniques reduce computational costs by up to 40%, while its foundation on open-source frameworks like PyTorch and TensorFlow ensures seamless integration for developers. Whether you're a startup, a developer, or a large enterprise, DeepSeek offers unparalleled transparency, affordability, and performance, making it a game-changer in the world of AI. Discover why DeepSeek is outshining competitors like ChatGPT and Google Gemini in this comprehensive guide.

Useful Python Libraries for Data Science & ML Enthusiasts

Hi there, DataSagar here! If you're as passionate about data science as I am, then you know how overwhelming it can be...

Most Popular

How to setup DNS Records in Cloudflare – Guide for Website Owners

Whether you're launching your first website, connecting a custom email address, or moving your domain to a new hosting provider, you've probably...

DeepSeek AI: The Open-Source AI Disruptor Shaking Up the Tech World

DeepSeek AI is revolutionizing the artificial intelligence landscape with its open-source, cost-effective, and highly customizable model. Built on cutting-edge transformer architecture and fine-tuned using reinforcement learning with human feedback (RLHF), DeepSeek delivers human-like text generation and accurate responses. Its efficient training techniques reduce computational costs by up to 40%, while its foundation on open-source frameworks like PyTorch and TensorFlow ensures seamless integration for developers. Whether you're a startup, a developer, or a large enterprise, DeepSeek offers unparalleled transparency, affordability, and performance, making it a game-changer in the world of AI. Discover why DeepSeek is outshining competitors like ChatGPT and Google Gemini in this comprehensive guide.

Useful Python Libraries for Data Science & ML Enthusiasts

Hi there, DataSagar here! If you're as passionate about data science as I am, then you know how overwhelming it can be...

Nepal Government allowing IT Companies to Invest Abroad

In a landmark decision that signals Nepal’s intent to embrace globalization and technological advancement, the government has now allowed Nepali IT companies...

Recent Comments