Monday 11 February 2019

Python Dictionaries - tccicomputercoaching.com

A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values.

Let us see how to define access and display dictionary.



Definition:

CarDict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}

Here, brand, model and year are keys and ford, Mustang and 1964 are their related values...

To access or get particular data from dictionary named CarDict

x = CarDict ["model"]

print(x)

We can change a specific data by referring to its key name:

Example

CarDict ["year"]=1965

To learn more in detail about Dictionary in python

You can join TCCI in Bopal and Satellite in Ahmedabad.

Call us @ 9825618292

Visit us @ http://tccicomputercoaching.com/corporate-training/

No comments:

Post a Comment