HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Glossary
  2. /Python and data
  3. /Dictionary (in Python)

What is Dictionary (in Python)?

In short

A dictionary stores pairs of a key and a value in curly brackets, such as {"H": 1.008, "C": 12.011}. You look up a value by its key.

In simple words

The keys must be unique and do not change, for example strings or numbers. To read a value, write masses["C"]. To add or change one, assign to it: masses["O"] = 15.999. A dictionary is the right choice for a lookup table, such as atomic masses, or for counting how many times each item occurs.

Example

This prints 18.015, the molar mass of water in grams per mole.

Learn it properly

  • Lessons on this topic
  • Test yourself

Related terms

  • List (in Python)
  • Function (in Python)

← All glossary terms

Learn it in

  1. Dictionaries: Look Things UpClass 9 to 10
All lessons on this topic →

Practise

  1. Group these words by their length, in a dictionary where the key is the length and the…Medium
  2. For this dictionary, write the expression for each answer…Medium
  3. Write a program that counts how many times each letter appears in the word mississippi…Easy
  4. Say whether a list or a dictionary is the better choice for each, and why…Easy

Quick questions

  1. A program counts the letters of a word in a dictionary, and then asks the dictionary…Hard
  2. A program updates a dictionary and asks it four questions. What does the program print?Hard
  3. A record inside a record: what is {"Ravi": {"age": 12, "marks": [70…Medium

More Python and data terms

  1. Cell (in a Python notebook)
  2. Class and Special Methods (in Python)
  3. For Loop
  4. If Statement (in Python)
  5. Import (Python modules and libraries)
  6. Mean, Median and Mode
All Python and data terms →

Try it yourself

Python labs run in your browser. Type the code, run it and see what happens.

Open a Python lab