{"id":38018,"date":"2016-10-15T17:14:14","date_gmt":"2016-10-15T22:14:14","guid":{"rendered":"http:\/\/union20.wordpress.com\/?p=367"},"modified":"2016-10-15T17:14:14","modified_gmt":"2016-10-15T22:14:14","slug":"dice","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/dice\/","title":{"rendered":"Dice"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/union20.wordpress.com\/2016\/10\/15\/dice\/\"><a href=\"https:\/\/union20.wordpress.com\">PYTHON 3 <\/a><\/a><\/em><br \/><\/p>\n<p>A month without posting any new blogs because of different reasons i&#8217;m back with some mini projects I&#8217;ve been developing since the beginning of the partial, this is the first one which is a program that rolls a dice, a very simple code.<\/p>\n<p>To do this program we need to import the random library, next we do our object &#8220;dice&#8221; as a list that includes the 6 numbers<\/p>\n<p><em>dice = [1,2,3,4,5,6]<\/em><\/p>\n<p>we print a welcome text and make an input to press enter and start a while loop, and while the loop is true it will run the next code:<\/p>\n<p><em>while True:<\/em><\/p>\n<p style=\"padding-left:30px;\"><em>pass <span style=\"color:#339966;\">#it will run the instructions in order<\/span><\/em><\/p>\n<p style=\"padding-left:30px;\"><em>print(&#8220;The number is: &#8221; , random.choice(dice)) <span style=\"color:#339966;\">#random.choice() selects a random object from a list<\/span><\/em><br \/>\n<em> print(&#8216;\\n&#8217;)<\/em><br \/>\n<em> print(&#8220;Want to roll again?&#8221;+&#8217;\\n&#8217;)<\/em><br \/>\n<em> print(&#8220;(1) Yes.&#8221;+&#8217;\\n&#8217;)<\/em><br \/>\n<em> print(&#8220;(2) No.&#8221;+&#8217;\\n&#8217;)<\/em><\/p>\n<p>Now the program has given a number from 1 to 6 and is asking us if we want to run it again<\/p>\n<p><em>answer = int(input(&#8216;\\n&#8217;))<\/em><\/p>\n<p style=\"text-align:left;padding-left:30px;\"><em>if answer == 2:<\/em><br \/>\n<em> break<\/em><\/p>\n<p style=\"text-align:left;padding-left:30px;\">\n<em> elif answer != 1:<\/em><br \/>\n<em> print(&#8220;Sorry but that&#8217;s not an option&#8230; Try again&#8221;+&#8217;\\n&#8217;)<\/em><\/p>\n<p style=\"text-align:left;\"><img class=\" size-full wp-image-389 aligncenter\" src=\"https:\/\/union20.files.wordpress.com\/2016\/10\/screenshot-from-2016-10-15-17-09-14.png?w=740\" alt=\"screenshot-from-2016-10-15-17-09-14\"   \/><\/p>\n<p style=\"text-align:left;\"><img class=\" size-full wp-image-391 aligncenter\" src=\"https:\/\/union20.files.wordpress.com\/2016\/10\/screenshot-from-2016-10-15-17-08-38.png?w=740\" alt=\"screenshot-from-2016-10-15-17-08-38\"   \/><\/p>\n<p style=\"text-align:left;\">\n<p style=\"text-align:left;\">Now i can play monopoly\u00a0with my own virtual dice<\/p>\n<p style=\"text-align:left;\"><img class=\" size-full wp-image-396 aligncenter\" src=\"https:\/\/union20.files.wordpress.com\/2016\/10\/monopoly.jpg?w=740\" alt=\"monopoly\"   \/><\/p><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/union20.wordpress.com\/367\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/union20.wordpress.com\/367\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=union20.wordpress.com&#038;blog=115237589&%23038;post=367&%23038;subd=union20&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at PYTHON 3 A month without posting any new blogs because of different reasons i&#8217;m back with some mini projects I&#8217;ve been developing since the beginning of the partial, this is the first one which is a program that rolls a dice, a very simple code. To do this program we need to &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/dice\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Dice<\/span><\/a><\/p>\n","protected":false},"author":29,"featured_media":389,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[89,148,33],"class_list":["post-38018","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\/38018","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=38018"}],"version-history":[{"count":3,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38018\/revisions"}],"predecessor-version":[{"id":38104,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38018\/revisions\/38104"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=38018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=38018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=38018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}