{"id":948,"date":"2017-12-05T21:21:09","date_gmt":"2017-12-05T21:21:09","guid":{"rendered":"http:\/\/learnlearn.uk\/python\/?page_id=948"},"modified":"2024-10-01T10:24:27","modified_gmt":"2024-10-01T10:24:27","slug":"forloops","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/python\/forloops\/","title":{"rendered":"Lesson 5 \u2013 for loops"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Basics Tutorial<\/h2>\n<div class=\"tabcontent\">\n\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1w3vJIJjO4Y56S0jKzm0DF_UWioH1Lz4z\/view?usp=sharing\">Can&#8217;t access YouTube? Click here for the Google Drive version<\/a><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/_lHwfYR_QTw\" width=\"853\" height=\"480\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n<\/div><h2 class=\"tabtitle\">Advanced Tutorial<\/h2>\n<div class=\"tabcontent\">\n\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1cMIrczdGyRyOBO4pg71hMmF_2YNNXS23\/view?usp=sharing\">Can&#8217;t access YouTube? Try the Google Drive link instead<\/a><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/8MEKchJhUoY\" width=\"853\" height=\"480\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Challenge 17<\/h2>\n<div class=\"tabcontent\">\n\n<p><strong>Challenge 17 &#8211; Message repeater<\/strong><\/p>\n<p>For this challenge you need to repeat a message a number of times.<\/p>\n<p><strong><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-886\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/bronze-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0Bronze<\/strong><\/p>\n<ul>\n<li>Using a for loop, repeat the message &#8216;Spam!&#8217; 20 times.<\/li>\n<li>Use a time.sleep() and os.system(&#8216;clear&#8217;) to make the message flash on and off the screen.<\/li>\n<\/ul>\n<p><strong><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-887\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/silver-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0Silver<\/strong><\/p>\n<ul>\n<li>Ask the user to what message they want to print out and print that out 20 times.<\/li>\n<li>Ask the user how many times they want to print out the message and repeat it that many times.<\/li>\n<\/ul>\n<p><strong><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-888\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/gold-star-25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0Gold<\/strong><\/p>\n<ul>\n<li>Check that the user has entered a string input for the message at least 5 characters long and repeat the question as necessary.<\/li>\n<li>Check that the user has entered a number input for the times and repeat the question if necessary.<\/li>\n<\/ul>\n\n<\/div><h2 class=\"tabtitle\">Challenge 18<\/h2>\n<div class=\"tabcontent\">\n\n<p><strong>Challenge 18 &#8211; Rocket Takeoff<\/strong><\/p>\n<p>Create a program that prints out a countdown and then prints out blastoff!<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-886\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/bronze-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Bronze<\/strong><\/p>\n<ul>\n<li>Your program should count down from 10 to zero, with a 1 second delay between each number<\/li>\n<li>Your program should finally say &#8211; &#8216;lift-off!&#8217;<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-887\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/silver-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Silver<\/strong><\/p>\n<ul>\n<li>Your program should include an ASCII art rocket.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-888\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/gold-star-25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Gold<\/strong><\/p>\n<ul>\n<li>Your ASCII art should be loaded from a separate file.<\/li>\n<li>Your ASCII art should be animated.<\/li>\n<\/ul>\n\n<\/div><h2 class=\"tabtitle\">Challenge 19<\/h2>\n<div class=\"tabcontent\">\n\n<p><strong>Challenge 19 &#8211; Number printer<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-886\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/bronze-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Bronze<\/strong><\/p>\n<ul>\n<li>Your program should print all of the numbers between 1 and 100<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-887\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/silver-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Silver<\/strong><\/p>\n<ul>\n<li>Your program should ask the user to input the 2 numbers(start and end) and print out all the numbers in between.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-888\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/gold-star-25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Gold<\/strong><\/p>\n<ul>\n<li>Your program should ask the user whether they want to print out all the numbers, just odd numbers, or just even numbers and print out the corresponding numbers.<\/li>\n<\/ul>\n\n<\/div><h2 class=\"tabtitle\">Challenge 20<\/h2>\n<div class=\"tabcontent\">\n\n<p><strong>Challenge 20 &#8211; Lap time recorder<\/strong><\/p>\n<p>The aim of this challenge is to record race lap times for a racer.<\/p>\n<p><span style=\"font-weight: 400;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-886\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/bronze-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Bronze<\/strong><\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">write a program that records the time in seconds taken to complete a lap of a race.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">You program should display the total time taken for the race<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-887\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/silver-star25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Silver<\/strong><\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Your program should display the lap number each time round.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Your program should program should display the average lap time.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-888\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/gold-star-25.png\" alt=\"\" width=\"25\" height=\"25\" \/>\u00a0<strong>Gold<\/strong><\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">You program should display the fastest and slowest lap time<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Your program should check if the user has entered a valid time for a lap. The program should keep asking until a valid time is entered.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Animated ASCII Art<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Animated ASCII Art video<\/h3>\n<div class=\"nv-iframe-embed\">\n<div class=\"container-lazyload preview-lazyload container-youtube js-lazyload--not-loaded\"><a href=\"https:\/\/www.youtube.com\/watch?v=JavJqJHLo_M\" class=\"lazy-load-youtube preview-lazyload preview-youtube\" data-video-title=\"Python Animated ASCII Art Tutorial\" title=\"Play video &quot;Python Animated ASCII Art Tutorial&quot;\">https:\/\/www.youtube.com\/watch?v=JavJqJHLo_M<\/a><noscript>Video can&#8217;t be loaded because JavaScript is disabled: <a href=\"https:\/\/www.youtube.com\/watch?v=JavJqJHLo_M\" title=\"Python Animated ASCII Art Tutorial\">Python Animated ASCII Art Tutorial (https:\/\/www.youtube.com\/watch?v=JavJqJHLo_M)<\/a><\/noscript><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Can&#8217;t access YouTube? Click here for the Google Drive version Can&#8217;t access YouTube? Try the Google Drive link instead &nbsp; Challenge 17 &#8211; Message repeater For this challenge you need to repeat a message a number of times. \u00a0Bronze Using a for loop, repeat the message &#8216;Spam!&#8217; 20 times. Use a time.sleep() and os.system(&#8216;clear&#8217;) to&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/python\/forloops\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Lesson 5 \u2013 for loops<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"off","neve_meta_content_width":100,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Lesson 5 \u2013 for loops - Python<\/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:\/\/learnlearn.uk\/python\/forloops\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Lesson 5 \u2013 for loops - Python\" \/>\n<meta property=\"og:description\" content=\"Can&#8217;t access YouTube? Click here for the Google Drive version Can&#8217;t access YouTube? Try the Google Drive link instead &nbsp; Challenge 17 &#8211; Message repeater For this challenge you need to repeat a message a number of times. \u00a0Bronze Using a for loop, repeat the message &#8216;Spam!&#8217; 20 times. Use a time.sleep() and os.system(&#8216;clear&#8217;) to&hellip;&nbsp;Read More &raquo;Lesson 5 \u2013 for loops\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/python\/forloops\/\" \/>\n<meta property=\"og:site_name\" content=\"Python\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-01T10:24:27+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/bronze-star25.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/python\/forloops\/\",\"url\":\"https:\/\/learnlearn.uk\/python\/forloops\/\",\"name\":\"Lesson 5 \u2013 for loops - Python\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/#website\"},\"datePublished\":\"2017-12-05T21:21:09+00:00\",\"dateModified\":\"2024-10-01T10:24:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/forloops\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/python\/forloops\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/python\/forloops\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Python Unit Home\",\"item\":\"https:\/\/learnlearn.uk\/python\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lesson 5 \u2013 for loops\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/python\/#website\",\"url\":\"https:\/\/learnlearn.uk\/python\/\",\"name\":\"Python\",\"description\":\"Programming\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/python\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/python\/#organization\",\"name\":\"Python\",\"url\":\"https:\/\/learnlearn.uk\/python\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png\",\"width\":710,\"height\":98,\"caption\":\"Python\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Lesson 5 \u2013 for loops - Python","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:\/\/learnlearn.uk\/python\/forloops\/","og_locale":"en_GB","og_type":"article","og_title":"Lesson 5 \u2013 for loops - Python","og_description":"Can&#8217;t access YouTube? Click here for the Google Drive version Can&#8217;t access YouTube? Try the Google Drive link instead &nbsp; Challenge 17 &#8211; Message repeater For this challenge you need to repeat a message a number of times. \u00a0Bronze Using a for loop, repeat the message &#8216;Spam!&#8217; 20 times. Use a time.sleep() and os.system(&#8216;clear&#8217;) to&hellip;&nbsp;Read More &raquo;Lesson 5 \u2013 for loops","og_url":"https:\/\/learnlearn.uk\/python\/forloops\/","og_site_name":"Python","article_modified_time":"2024-10-01T10:24:27+00:00","og_image":[{"url":"http:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2017\/09\/bronze-star25.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/python\/forloops\/","url":"https:\/\/learnlearn.uk\/python\/forloops\/","name":"Lesson 5 \u2013 for loops - Python","isPartOf":{"@id":"https:\/\/learnlearn.uk\/python\/#website"},"datePublished":"2017-12-05T21:21:09+00:00","dateModified":"2024-10-01T10:24:27+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/python\/forloops\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/python\/forloops\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/python\/forloops\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Python Unit Home","item":"https:\/\/learnlearn.uk\/python\/"},{"@type":"ListItem","position":2,"name":"Lesson 5 \u2013 for loops"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/python\/#website","url":"https:\/\/learnlearn.uk\/python\/","name":"Python","description":"Programming","publisher":{"@id":"https:\/\/learnlearn.uk\/python\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/python\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/python\/#organization","name":"Python","url":"https:\/\/learnlearn.uk\/python\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png","contentUrl":"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png","width":710,"height":98,"caption":"Python"},"image":{"@id":"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/python\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"Can&#8217;t access YouTube? Click here for the Google Drive version Can&#8217;t access YouTube? Try the Google Drive link instead &nbsp; Challenge 17 &#8211; Message repeater For this challenge you need to repeat a message a number of times. \u00a0Bronze Using a for loop, repeat the message &#8216;Spam!&#8217; 20 times. Use a time.sleep() and os.system(&#8216;clear&#8217;) to&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages\/948"}],"collection":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/comments?post=948"}],"version-history":[{"count":12,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages\/948\/revisions"}],"predecessor-version":[{"id":1488,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages\/948\/revisions\/1488"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/media?parent=948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}