{"id":676,"date":"2023-03-29T16:15:11","date_gmt":"2023-03-29T16:15:11","guid":{"rendered":"https:\/\/tinyytopic.com\/?p=676"},"modified":"2023-03-29T16:15:09","modified_gmt":"2023-03-29T16:15:09","slug":"use-of-dictionary-in-python","status":"publish","type":"post","link":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/","title":{"rendered":"Use of dictionary in python"},"content":{"rendered":"\n<p style=\"font-size:16px\"><br>In Python, a dictionary is a collection of key-value pairs, where each key is unique and corresponds to a value. Dictionaries are also known as associative arrays, hash tables, or maps in other programming languages.<\/p>\n\n\n\n<p style=\"font-size:16px\"><br>Here is an example of a dictionary in Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>my_dict = {\r\n    \"apple\": 2.99,\r\n    \"banana\": 1.99,\r\n    \"orange\": 0.99,\r\n    \"kiwi\": 3.49\r\n}\r<\/code><\/pre>\n\n\n\n<p style=\"font-size:16px\">In this example, the <code>my_dict<\/code> dictionary contains four key-value pairs, where the keys are strings that represent different fruits, and the values are floating-point numbers that represent their prices.<\/p>\n\n\n\n<p style=\"font-size:16px\"><br>You can access the values in a dictionary by using the keys. For example, to access the price of an apple in the <code>my_dict<\/code> dictionary, you can do the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apple_price = my_dict&#91;\"apple\"]\r\nprint(\"The price of an apple is:\", apple_price)  \n# Output: The price of an apple is: 2.99\r<\/code><\/pre>\n\n\n\n<p style=\"font-size:16px\">In this example, the value of the <code>apple<\/code> key is accessed using square brackets and assigned to the <code>apple_price<\/code> variable.<\/p>\n\n\n\n<p style=\"font-size:16px\"><br>You can also add, modify, and delete key-value pairs in a dictionary. For example, to add a new key-value pair to the <code>my_dict<\/code> dictionary, you can do the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>my_dict&#91;\"pear\"] = 1.49\r\nprint(my_dict)  \n# Output: {'apple': 2.99, 'banana': 1.99, 'orange': 0.99, 'kiwi': 3.49, 'pear': 1.49}\r<\/code><\/pre>\n\n\n\n<p style=\"font-size:16px\">In this example, a new key-value pair with the key <code>\"pear\"<\/code> and the value <code>1.49<\/code> is added to the <code>my_dict<\/code> dictionary using square brackets.<\/p>\n\n\n\n<p style=\"font-size:16px\"><br>Dictionaries are very useful when you need to store and retrieve data using a key, especially when the data is not in a sequential order like a list or tuple.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Python, a dictionary is a collection of key-value pairs, where each key is unique and corresponds to a value. Dictionaries are also known as associative arrays, hash tables, or maps in other programming languages. Here is an example of a dictionary in Python: In this example, the my_dict dictionary contains four key-value pairs, where [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[42,12],"tags":[90,14,13,16,80],"class_list":["post-676","post","type-post","status-publish","format-standard","hentry","category-general-qa","category-python","tag-dictionary","tag-programming-language","tag-python","tag-python-code","tag-python-qna"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use of dictionary in python - tinyytopic.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use of dictionary in python - tinyytopic.com\" \/>\n<meta property=\"og:description\" content=\"In Python, a dictionary is a collection of key-value pairs, where each key is unique and corresponds to a value. Dictionaries are also known as associative arrays, hash tables, or maps in other programming languages. Here is an example of a dictionary in Python: In this example, the my_dict dictionary contains four key-value pairs, where [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"tinyytopic.com\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-29T16:15:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-29T16:15:09+00:00\" \/>\n<meta name=\"author\" content=\"tinyytopic.com\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"tinyytopic.com\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/\",\"url\":\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/\",\"name\":\"Use of dictionary in python - tinyytopic.com\",\"isPartOf\":{\"@id\":\"https:\/\/tinyytopic.com\/#website\"},\"datePublished\":\"2023-03-29T16:15:11+00:00\",\"dateModified\":\"2023-03-29T16:15:09+00:00\",\"author\":{\"@id\":\"https:\/\/tinyytopic.com\/#\/schema\/person\/56c840cea8539fb221a03c5fa2ef32eb\"},\"breadcrumb\":{\"@id\":\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tinyytopic.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use of dictionary in python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tinyytopic.com\/#website\",\"url\":\"https:\/\/tinyytopic.com\/\",\"name\":\"tinyytopic.com\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tinyytopic.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tinyytopic.com\/#\/schema\/person\/56c840cea8539fb221a03c5fa2ef32eb\",\"name\":\"tinyytopic.com\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tinyytopic.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5f153681c8ca1e6d7287d858de51f968bb687221c89cf96d763ead4393881029?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5f153681c8ca1e6d7287d858de51f968bb687221c89cf96d763ead4393881029?s=96&d=mm&r=g\",\"caption\":\"tinyytopic.com\"},\"sameAs\":[\"http:\/\/tinyytopic.com\"],\"url\":\"https:\/\/tinyytopic.com\/index.php\/author\/mmkmuthukumar21gmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Use of dictionary in python - tinyytopic.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Use of dictionary in python - tinyytopic.com","og_description":"In Python, a dictionary is a collection of key-value pairs, where each key is unique and corresponds to a value. Dictionaries are also known as associative arrays, hash tables, or maps in other programming languages. Here is an example of a dictionary in Python: In this example, the my_dict dictionary contains four key-value pairs, where [&hellip;]","og_url":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/","og_site_name":"tinyytopic.com","article_published_time":"2023-03-29T16:15:11+00:00","article_modified_time":"2023-03-29T16:15:09+00:00","author":"tinyytopic.com","twitter_card":"summary_large_image","twitter_misc":{"Written by":"tinyytopic.com","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/","url":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/","name":"Use of dictionary in python - tinyytopic.com","isPartOf":{"@id":"https:\/\/tinyytopic.com\/#website"},"datePublished":"2023-03-29T16:15:11+00:00","dateModified":"2023-03-29T16:15:09+00:00","author":{"@id":"https:\/\/tinyytopic.com\/#\/schema\/person\/56c840cea8539fb221a03c5fa2ef32eb"},"breadcrumb":{"@id":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tinyytopic.com\/index.php\/2023\/03\/29\/use-of-dictionary-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tinyytopic.com\/"},{"@type":"ListItem","position":2,"name":"Use of dictionary in python"}]},{"@type":"WebSite","@id":"https:\/\/tinyytopic.com\/#website","url":"https:\/\/tinyytopic.com\/","name":"tinyytopic.com","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tinyytopic.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tinyytopic.com\/#\/schema\/person\/56c840cea8539fb221a03c5fa2ef32eb","name":"tinyytopic.com","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tinyytopic.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5f153681c8ca1e6d7287d858de51f968bb687221c89cf96d763ead4393881029?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5f153681c8ca1e6d7287d858de51f968bb687221c89cf96d763ead4393881029?s=96&d=mm&r=g","caption":"tinyytopic.com"},"sameAs":["http:\/\/tinyytopic.com"],"url":"https:\/\/tinyytopic.com\/index.php\/author\/mmkmuthukumar21gmail-com\/"}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"tinyytopic.com","author_link":"https:\/\/tinyytopic.com\/index.php\/author\/mmkmuthukumar21gmail-com\/"},"uagb_comment_info":4,"uagb_excerpt":"In Python, a dictionary is a collection of key-value pairs, where each key is unique and corresponds to a value. Dictionaries are also known as associative arrays, hash tables, or maps in other programming languages. Here is an example of a dictionary in Python: In this example, the my_dict dictionary contains four key-value pairs, where&hellip;","_links":{"self":[{"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/posts\/676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/comments?post=676"}],"version-history":[{"count":2,"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/posts\/676\/revisions"}],"predecessor-version":[{"id":678,"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/posts\/676\/revisions\/678"}],"wp:attachment":[{"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/media?parent=676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/categories?post=676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tinyytopic.com\/index.php\/wp-json\/wp\/v2\/tags?post=676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}