{"id":1350,"date":"2024-12-27T15:35:54","date_gmt":"2024-12-27T14:35:54","guid":{"rendered":"https:\/\/vroamam.com\/wordpress\/?p=1350"},"modified":"2024-12-27T15:35:54","modified_gmt":"2024-12-27T14:35:54","slug":"day-9-dictionaries","status":"publish","type":"post","link":"https:\/\/vroamam.com\/wordpress\/blog\/day-9-dictionaries\/","title":{"rendered":"Day 9 &#8211; Dictionaries"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>Day 9 Goals<\/li>\n\n\n\n<li>The Python Dictionary<\/li>\n\n\n\n<li>Coding Exercise: Grading Scores<\/li>\n\n\n\n<li>Nesting List and Dictionaries<\/li>\n\n\n\n<li>Project: The Secret Auction<\/li>\n<\/ul>\n\n\n\n<p>Coding Exercise &#8211; Grading Scores.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># You have access to a database of student_scores in the format of a dictionary. \n# The keys in student_scores are the names of the students\n# The values are their exam scores. \n\n# Write a program that converts their scores to grades.\n# **DO NOT** modify lines 1-7 to change the existing student_scores dictionary. \n\nWrite a program that converts their scores to grades.\nstudent_scores = {\n    'Harry': 88,\n    'Ron': 78,\n    'Hermione': 95,\n    'Draco': 75,\n    'Neville': 60\n}\n\nstudent_grades = {}\n\nfor key in student_scores:\n    if student_scores&#91;key] > 90:\n        student_grades&#91;key] = \"Outstanding\"\n    elif student_scores&#91;key] > 80:\n        student_grades&#91;key] = \"Exceeds Expectations\"\n    elif student_scores&#91;key] > 70:\n        student_grades&#91;key] = \"Acceptable\"\n    else:\n        student_grades&#91;key] = \"Fail\"\n\nprint(student_grades)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Project: Blind Auction<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from art import logo\n\n# TODO-1: Ask the user for input\n# TODO-2: Save data into dictionary {name: price}\n# TODO-3: Whether if new bids need to be added\n# TODO-4: Compare bids in dictionary\n\n# gather all the bids\nall_bidders = {}\nprint(logo)\nmore_bidders = True\nwhile more_bidders:\n    name = input(\"What is your name?: \")\n    bid = int(input(\"What is your bid?: $\"))\n    # add bids to a list\n    all_bidders&#91;name] = bid\n    more_bidders = input(\"Are there any other bidders? Type 'yes or 'no'.\\n\").lower()\n    print(\"\\n\" * 20)\n    print(logo)\n    if more_bidders == \"no\":\n        more_bidders = False\n\n# find the highest bid\nmax_value = 0\nmax_key = \"\"\nfor key, value in all_bidders.items():\n    print(f\"{key} bid ${value}\")\n    if value > max_value:\n        max_value = value\n        max_key = key\n\n# print the winners details\nprint(f\"the winner was {max_key} with a bid of ${max_value}\")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Coding Exercise &#8211; Grading Scores. Project: Blind Auction<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[144,148,3],"tags":[146,145,11],"class_list":["post-1350","post","type-post","status-publish","format-standard","hentry","category-100daysofcode","category-python","category-training","tag-100daysofcode","tag-python","tag-training","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pahuGk-lM","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1350"}],"version-history":[{"count":4,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1350\/revisions"}],"predecessor-version":[{"id":1354,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1350\/revisions\/1354"}],"wp:attachment":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}