Python Lab Manual / Python dictionaries Program

Program Name

Write a Python dictionaries Program.
Theory
Dictionary in Python used to store unordered collection of data values which stores mappings of unique keys to values. Dictionaries are written with curly brackets ({}), including key-value pairs separated by commas (,). A colon (:) separates each key from its value.
Program Code


Input and Output:
Output:
Creating an empty Dictionary
{}

Dictionary with keys
{1: 'wisdom', 2: 'For', 3: 'materials'}

Creating a Dictionary with Mixed Keys
{'Name': 'wisdom', 1: [1, 2, 3, 4]}

Creating a Dictionary with dict() method
{1: 'python', 2: 'For', 3: 'language'}

Creating a Dictionary with each item as a Pair
{1: 'python1', 2: 'language1'}

 Delete key from Dictionary
{2: 'For', 3: 'materials'}

print a dictionary
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}


Home     Back