{"id":37509,"date":"2016-09-09T09:29:26","date_gmt":"2016-09-09T14:29:26","guid":{"rendered":"http:\/\/union20.wordpress.com\/?p=288"},"modified":"2016-09-09T09:29:26","modified_gmt":"2016-09-09T14:29:26","slug":"while-2","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/while-2\/","title":{"rendered":"While\u2026"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/union20.wordpress.com\/2016\/09\/09\/while\/\"><a href=\"https:\/\/union20.wordpress.com\">PYTHON 3 <\/a><\/a><\/em><br \/><\/p>\n<p>The <strong><em>whiles<\/em><\/strong>\u00a0are useful when we need to make a loop in our code, by this I mean that after we are done with a set of instructions maybe we want to repeat the same instructions one more time, and another and another and another\u2026.., until a statement tells it to stop or even the user wants to make it stop.<\/p>\n<p>The <strong><i>while<\/i><\/strong> differentiates from the <strong><i>for<\/i><\/strong> because we use when we don\u2019t know how many times the code will execute, with the <strong><i>for<\/i><\/strong> we tell the program how many times to repeat the loop.<\/p>\n<p><img class=\"alignnone size-full wp-image-294\" src=\"https:\/\/union20.files.wordpress.com\/2016\/09\/screenshot-from-2016-09-09-09-10-58.png?w=740\" alt=\"screenshot-from-2016-09-09-09-10-58\"   \/><\/p>\n<p>Here I am telling the program to generate a random number from 0 to 10, I am also creating an int variable x =1,<\/p>\n<p>so if my random number is less or equal than 20, my random number will be added the x=1, and after that I am printing all the numbers till it gets equal to 20.<\/p>\n<p>This is a while loop because I don&#8217;t know my initial number, maybe my initial random is 0 or 10, and one may need more loops to reach 20 than the another, that&#8217;s why I use a while, because I don&#8217;t know how many times to repeat the instructions until it reach the goal.<\/p>\n<p><img class=\"alignnone size-full wp-image-302\" src=\"https:\/\/union20.files.wordpress.com\/2016\/09\/screenshot-from-2016-09-09-09-21-37.png?w=740\" alt=\"screenshot-from-2016-09-09-09-21-37\"   \/><\/p>\n<p><img class=\"alignnone size-full wp-image-303\" src=\"https:\/\/union20.files.wordpress.com\/2016\/09\/screenshot-from-2016-09-09-09-21-53.png?w=740\" alt=\"screenshot-from-2016-09-09-09-21-53\"   \/><\/p>\n<p>I learned while loops from here&#8230;<img src=\"https:\/\/s0.wp.com\/wp-content\/mu-plugins\/wpcom-smileys\/twemoji\/2\/72x72\/1f642.png\" alt=\"?\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> Check it out<\/p>\n<p><a href=\"http:\/\/www.python-course.eu\/python3_loops.php\" rel=\"nofollow\">http:\/\/www.python-course.eu\/python3_loops.php<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/union20.wordpress.com\/288\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/union20.wordpress.com\/288\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=union20.wordpress.com&#038;blog=115237589&%23038;post=288&%23038;subd=union20&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at PYTHON 3 The whiles\u00a0are useful when we need to make a loop in our code, by this I mean that after we are done with a set of instructions maybe we want to repeat the same instructions one more time, and another and another and another\u2026.., until a statement tells it to &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/while-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">While\u2026<\/span><\/a><\/p>\n","protected":false},"author":29,"featured_media":294,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[89,148,33],"class_list":["post-37509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-python3","tag-learning","tag-tc101"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=37509"}],"version-history":[{"count":3,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37509\/revisions"}],"predecessor-version":[{"id":38106,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37509\/revisions\/38106"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=37509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=37509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=37509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}