Dictionaries, भाग 2

इंटरमीडिएट Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

पुनरावलोकन

world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21}

world["albania"]
2.77
world = {"afghanistan":30.55, "albania":2.77, 
         "algeria":39.21, "albania":2.81}

world
{'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
इंटरमीडिएट Python

पुनरावलोकन

  • Keys "immutable" objects होने चाहिए
{0:"hello", True:"dear", "two":"world"}
{0: 'hello', True: 'dear', 'two': 'world'}
{["just", "to", "test"]: "value"}
TypeError: unhashable type: 'list'
इंटरमीडिएट Python

प्रिंसिपैलिटी ऑफ़ सीलैंड

ch2_2_slides.015.png

1 स्रोत: Wikipedia
इंटरमीडिएट Python

डिक्शनरी

world["sealand"] = 0.000027

world
{'afghanistan': 30.55, 'albania': 2.81, 
        'algeria': 39.21, 'sealand': 2.7e-05}
"sealand" in world
True
इंटरमीडिएट Python

डिक्शनरी

world["sealand"] = 0.000028

world
{'afghanistan': 30.55, 'albania': 2.81, 
        'algeria': 39.21, 'sealand': 2.8e-05}
del(world["sealand"])

world
{'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
इंटरमीडिएट Python

List बनाम Dictionary

इंटरमीडिएट Python

List बनाम Dictionary

इंटरमीडिएट Python

List बनाम Dictionary

List Dictionary
[] से select, update, और remove करें [] से select, update, और remove करें
इंटरमीडिएट Python

List बनाम Dictionary

List Dictionary
[] से select, update, और remove करें [] से select, update, और remove करें
इंटरमीडिएट Python

List बनाम Dictionary

List Dictionary
[] से select, update, और remove करें [] से select, update, और remove करें
नंबर रेंज से indexed
इंटरमीडिएट Python

List बनाम Dictionary

List Dictionary
[] से select, update, और remove करें [] से select, update, और remove करें
नंबर रेंज से indexed यूनिक keys से indexed
इंटरमीडिएट Python

List बनाम Dictionary

List Dictionary
[] से select, update, और remove करें [] से select, update, और remove करें
नंबर रेंज से indexed यूनिक keys से indexed
मानों का collection — order मायने रखता है, पूरे subsets चुनने के लिए
इंटरमीडिएट Python

List बनाम Dictionary

List Dictionary
[] से select, update, और remove करें [] से select, update, और remove करें
नंबर रेंज से indexed यूनिक keys से indexed
मानों का collection — order मायने रखता है, पूरे subsets चुनने के लिए यूनिक keys वाली lookup table
इंटरमीडिएट Python

अभ्यास करते हैं!

इंटरमीडिएट Python

Preparing Video For Download...