{"id":1314,"date":"2024-12-27T14:54:41","date_gmt":"2024-12-27T13:54:41","guid":{"rendered":"https:\/\/vroamam.com\/wordpress\/?p=1314"},"modified":"2024-12-27T14:54:41","modified_gmt":"2024-12-27T13:54:41","slug":"day-5-python-loops","status":"publish","type":"post","link":"https:\/\/vroamam.com\/wordpress\/blog\/day-5-python-loops\/","title":{"rendered":"Day 5 &#8211; Python Loops"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>Day 5 Goals<\/li>\n\n\n\n<li>For Loop<\/li>\n\n\n\n<li>sum()<\/li>\n\n\n\n<li>range() function<\/li>\n\n\n\n<li>Coding Challenge: FizzBuzz<\/li>\n\n\n\n<li>Project: Password Generator<\/li>\n<\/ul>\n\n\n\n<p>My fizzbuzz challenge<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># You are going to write a program that prints the solution to the FizzBuzz game. \n#These are the rules of the FizzBuzz game:\n\n# Your program should print each number from 1 to 100 in turn and include number 100.\n# when the number is divisible by 3 then it should print \"Fizz\".\n# when the number is divisible by 5, then it should print \"Buzz\".`\n# and if the number is divisible by both 3 and 5 e.g. 15 then it should print \"FizzBuzz\"\n\nfor i in range(1,101):\n    if (i % 3 == 0) and (i % 5 == 0):\n        print(\"FizzBuzz\")\n    elif i % 5 ==0:\n        print(\"Buzz\")\n    elif i % 3 == 0:\n        print(\"Fizz\")\n    else:\n        print(i)<\/code><\/pre>\n\n\n\n<p>My project: <\/p>\n\n\n\n<p>Password Generator (Letter, Symbols, Numbers in sequence)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># create a random password using the lists of letters, numbers and symbols\n# ask the user how many of each they want\n# print the generated password\n\nimport random\nfrom email.contentmanager import raw_data_manager\n\nletters = &#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', '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']\nnumbers = &#91;'0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\nsymbols = &#91;'!', '#', '$', '%', '&amp;', '(', ')', '*', '+']\n\nprint(\"Welcome to the PyPassword Generator!\")\nnr_letters = int(input(\"How many letters would you like in your password?\\n\"))\nnr_symbols = int(input(f\"How many symbols would you like?\\n\"))\nnr_numbers = int(input(f\"How many numbers would you like?\\n\"))\n\n\n# with no randomisation of the character places\npwd = \"\"\nfor nrl in range(0, nr_letters):\n    i = random.randint(0, len(letters) - 1)\n    pwd = pwd + letters&#91;i]\nfor nrs in range(0, nr_symbols):\n    i = random.randint(0, len(numbers) - 1)\n    pwd = pwd + symbols&#91;i]\nfor nrn in range(0, nr_numbers):\n    i = random.randint(0, len(symbols) - 1)\n    pwd = pwd + numbers&#91;i]\nprint(f\"Your simple password is {pwd}\")\n\n<\/code><\/pre>\n\n\n\n<p>Password Generator (Randomised Characters)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># create a random password using the lists of letters, numbers and symbols\n# ask the user how many of each they want\n# randomise the position of each character.\n# print the generated password\nimport random\nfrom email.contentmanager import raw_data_manager\n\nletters = &#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', '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']\nnumbers = &#91;'0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\nsymbols = &#91;'!', '#', '$', '%', '&amp;', '(', ')', '*', '+']\n\nprint(\"Welcome to the PyPassword Generator!\")\nnr_letters = int(input(\"How many letters would you like in your password?\\n\"))\nnr_symbols = int(input(f\"How many symbols would you like?\\n\"))\nnr_numbers = int(input(f\"How many numbers would you like?\\n\"))\n\n# with place randomisation\npwd_lst = &#91;]\nfor nrl in range(0, nr_letters):\n    i = random.randint(0, len(letters) - 1)\n    pwd_lst.append(letters&#91;i])\nfor nrs in range(0, nr_symbols):\n    i = random.randint(0, len(symbols) - 1)\n    pwd_lst.append(symbols&#91;i])\nfor nrn in range(0, nr_numbers):\n    i = random.randint(0, len(symbols) - 1)\n    pwd_lst.append(numbers&#91;i])\n\n# now we have selected random number letters and symbols we need to randomise them in the list\npwd_str = \"\"\nrandom.shuffle(pwd_lst) # this uses the random module to randomise the list\n\n# and now convert the list to a string - here I am doing it using only code we have used so far\nfor i in range(0, len(pwd_lst)):\n    pwd_str += pwd_lst&#91;i] # iterate through the list, take each character and concatenate it to a string\nprint(f\"your random password is {pwd_str}\")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>My fizzbuzz challenge My project: Password Generator (Letter, Symbols, Numbers in sequence) Password Generator (Randomised Characters)<\/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-1314","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-lc","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1314","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=1314"}],"version-history":[{"count":3,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1314\/revisions"}],"predecessor-version":[{"id":1317,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/1314\/revisions\/1317"}],"wp:attachment":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}