{"id":1325,"date":"2024-12-27T14:54:41","date_gmt":"2024-12-27T13:54:41","guid":{"rendered":"https:\/\/vroamam.com\/wordpress\/?p=1325"},"modified":"2024-12-27T15:12:25","modified_gmt":"2024-12-27T14:12:25","slug":"day-8","status":"publish","type":"post","link":"https:\/\/vroamam.com\/wordpress\/blog\/day-8\/","title":{"rendered":"Day 8 &#8211; Function Parameters &amp; Caesar Cipher"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>Day 8 Goals<\/li>\n\n\n\n<li>Functions with Inputs<\/li>\n\n\n\n<li>Coding Exercise : Life in Weeks<\/li>\n\n\n\n<li>Positional vs Keyword arguments<\/li>\n\n\n\n<li>Coding Exercise: Love Calculator<\/li>\n\n\n\n<li>Caeser Cipher Part 1 &#8211; Encryption<\/li>\n\n\n\n<li>Caeser Cipher Part 2 &#8211; Decryption<\/li>\n\n\n\n<li>Caeser Cipher Part 3 &#8211; Reorganising the code<\/li>\n<\/ul>\n\n\n\n<p>Project &#8211; Caeser Cipher (completed)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># TODO-1: Import and print the logo from art.py when the program starts.\nfrom art import logo\n# alphabet provided as a list\nalphabet = &#91;'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n\n# function to complete the encoding\/decoding\ndef caesar(original_text, shift_amount, encode_or_decode):\n    output_text = \"\"\n    if encode_or_decode == \"decode\":\n        shift_amount *= -1\n\n    for letter in original_text:\n        if letter in alphabet:\n            shifted_position = alphabet.index(letter) + shift_amount\n            shifted_position %= len(alphabet)\n            output_text += alphabet&#91;shifted_position]\n# TODO-2: What happens if the user enters a number\/symbol\/space?\n        else:\n            output_text += letter\n    print(f\"Here is the {encode_or_decode}d result: {output_text}\")\n\n\n# TODO-3: Can you figure out a way to restart the cipher program?\nprint(logo) # print ascii art\nanswer = \"yes\" #set the answer variable to start the while loop\n\n# iterate through the loop as long as the user keeps typing \"yes\" at the end\nwhile answer == \"yes\":\n    direction = input(\"Type 'encode' to encrypt, type 'decode' to decrypt:\\n\").lower()\n    text = input(\"Type your message:\\n\").lower()\n    shift = int(input(\"Type the shift number:\\n\"))\n    caesar(original_text=text, shift_amount=shift, encode_or_decode=direction)\n    answer = input(\"Press 'yes' to restart or type 'no' to exit.\\n\")\n\n# print a closing message\nprint(\"Thank you for using Caesar's Cipher. Beware the Ides of March\")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Project &#8211; Caeser Cipher (completed)<\/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":false,"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-1325","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-ln","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1325","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=1325"}],"version-history":[{"count":3,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1325\/revisions"}],"predecessor-version":[{"id":1344,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1325\/revisions\/1344"}],"wp:attachment":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}