{"id":3698,"date":"2023-03-01T14:39:32","date_gmt":"2023-03-01T19:39:32","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/?p=3698"},"modified":"2023-03-01T14:39:32","modified_gmt":"2023-03-01T19:39:32","slug":"why-do-we-use-loops-6b","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/2023\/03\/01\/why-do-we-use-loops-6b\/","title":{"rendered":"Why do we use Loops? 6B"},"content":{"rendered":"<p>Loops are used to automate repetitive tasks and to iterate over collections of data, such as lists and dictionaries. They help to reduce the amount of code needed to perform complex operations, making code more concise and efficient.<\/p>\n<p>We use a for loop when we want the code to run a specific number of times.<\/p>\n<p>We would use a while loop when we don&#8217;t know the specific number of times. A while loop will continue running until a certain condition is met, while a for loop requires an initial setup, including the number of iterations that will run.<\/p>\n<ol>\n<li>The initialization: This is where the counter variable (or loop variable) is initialized.<\/li>\n<li>The condition: This is a boolean expression that determines whether or not the loop should continue to run.<\/li>\n<li>The increment\/decrement: This section defines how the counter variable will change after each iteration of the loop.<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-3701\" src=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/th-3-300x168.jpeg\" alt=\"\" width=\"300\" height=\"168\" srcset=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/th-3-300x168.jpeg 300w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/th-3.jpeg 474w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Loops are used to automate repetitive tasks and to iterate over collections of data, such as lists and dictionaries. They help to reduce the amount of code needed to perform complex operations, making code more concise and efficient. We use a for loop when we want the code to run a specific number of times. [&hellip;]<\/p>\n","protected":false},"author":29452,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[10531],"tags":[685722,845102,845092,845006,178,845115],"class_list":{"0":"post-3698","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-student-post","7":"tag-digital-identity","8":"tag-for-loop","9":"tag-functions","10":"tag-loops","11":"tag-mis","12":"tag-while-loop","13":"entry"},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/users\/29452"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/comments?post=3698"}],"version-history":[{"count":1,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3698\/revisions"}],"predecessor-version":[{"id":3702,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3698\/revisions\/3702"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/media?parent=3698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/categories?post=3698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/tags?post=3698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}