{"id":255,"date":"2023-06-18T13:18:11","date_gmt":"2023-06-18T13:18:11","guid":{"rendered":"https:\/\/joseph-t-gordon.tech\/?p=255"},"modified":"2023-06-26T14:24:45","modified_gmt":"2023-06-26T14:24:45","slug":"post-45-dictionaries-within-python","status":"publish","type":"post","link":"https:\/\/joseph-t-gordon.tech\/index.php\/2023\/06\/18\/post-45-dictionaries-within-python\/","title":{"rendered":"Post #46 (Python Programming) &#8211; Dictionaries within Python"},"content":{"rendered":"\n<p>Today I will be talking about dictionaries in python. Dictionaries use a key-value pair. For example I need the phone number of my friend Bob, I look up the name Bob and there&#8217;s his number. This is a good example of what dictionaries are used for but what do they look like?<\/p>\n\n\n\n<p>Ex:<\/p>\n\n\n\n<p>Dictionary = {&#8220;Dog&#8221;: &#8220;Puppy&#8221;, &#8220;Cat&#8221;: &#8220;Kitten&#8221;, &#8220;Duck&#8221;: &#8220;Duckling&#8221;}<\/p>\n\n\n\n<p>print(Dictionary)<\/p>\n\n\n\n<p>print(Dictionary[&#8220;Duck&#8221;])<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Result:<\/p>\n\n\n\n<p>{&#8220;Dog&#8221;: &#8220;Puppy&#8221;, &#8220;Cat&#8221;: &#8220;Kitten&#8221;, &#8220;Duck&#8221;: &#8220;Duckling&#8221;}<\/p>\n\n\n\n<p>Duckling<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Key-values pairs are separates by a colon and different pairs separated by comma. It doesn&#8217;t have to be string-string it can be string-integer, string-float, float-string, integer-integer, etc. You can print the entire dictionary or you can print a specific value by querying a key. As you can see from print(Dictionary[&#8220;Duck&#8221;]) I was able to print the value by utilizing its key.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I will be talking about dictionaries in python. Dictionaries use a key-value pair. For example I need the phone number of my friend Bob, I look up the name Bob and there&#8217;s his number. This is a good example of what dictionaries are used for but what do they look like? Ex: Dictionary =&#8230;<\/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,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/posts\/255"}],"collection":[{"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":3,"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":330,"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions\/330"}],"wp:attachment":[{"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joseph-t-gordon.tech\/index.php\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}