{"id":312,"date":"2017-05-25T06:04:52","date_gmt":"2017-05-25T06:04:52","guid":{"rendered":"https:\/\/www.triptera.com.au\/wordpress\/?p=312"},"modified":"2017-05-27T09:37:02","modified_gmt":"2017-05-27T09:37:02","slug":"coderdojo-turtle-racing-4-countdown-timer","status":"publish","type":"post","link":"https:\/\/www.triptera.com.au\/wordpress\/2017\/05\/25\/coderdojo-turtle-racing-4-countdown-timer\/","title":{"rendered":"CoderDojo turtle racing &#8211; 4 &#8211; countdown timer"},"content":{"rendered":"<p>To make this race more realistic, lets give our turtle a countdown timer so he knows when to start!<\/p>\n<p>Find the following lines in the bumpy top example.<\/p>\n<pre class=\"brush: python; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n# start\r\nstart = time.time()\r\n<\/pre>\n<p>And replace them with these lines so that the turtle knows when to start.<\/p>\n<pre class=\"brush: python; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n# count down to start\r\nfor countdown in &#x5B;&quot;5&quot;,&quot;4&quot;,&quot;3&quot;,&quot;2&quot;,&quot;1&quot;]:\r\n  scorer.write(&quot;Time to start &quot; + countdown,font=f)\r\n  time.sleep(1)\r\n  scorer.clear()\r\nstart = time.time()\r\n<\/pre>\n<p>The &#8220;for&#8221; command creates a loop in the code which can save a lot of time. All the indented lines after the &#8220;for&#8221; command are run for each different value of &#8220;countdown&#8221;. The list [&#8220;5&#8243;,&#8221;4&#8243;,&#8221;3&#8243;,&#8221;2&#8243;,&#8221;1&#8221;] is all the different values of countdown.<\/p>\n<p>Once you have that working, you can try replacing [&#8220;5&#8243;,&#8221;4&#8243;,&#8221;3&#8243;,&#8221;2&#8243;,&#8221;1&#8221;] with [&#8220;ready&#8221;,&#8221;set&#8221;,&#8221;go&#8221;]. <\/p>\n<p>NEXT: Try creating your own track!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To make this race more realistic, lets give our turtle a countdown timer so he knows when to start! Find the following lines in the bumpy top example. # start start = time.time() And replace them with these lines so that the turtle knows when to start. # count down to start for countdown in [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[13],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-coderdojo"],"_links":{"self":[{"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/comments?post=312"}],"version-history":[{"count":2,"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/312\/revisions\/350"}],"wp:attachment":[{"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/media?parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/categories?post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.triptera.com.au\/wordpress\/wp-json\/wp\/v2\/tags?post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}