{"id":38151,"date":"2016-10-23T16:56:36","date_gmt":"2016-10-23T21:56:36","guid":{"rendered":"http:\/\/firstprogrammingsteps.wordpress.com\/?p=228"},"modified":"2016-10-23T16:56:36","modified_gmt":"2016-10-23T21:56:36","slug":"foolproof","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/foolproof\/","title":{"rendered":"Foolproof."},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/firstprogrammingsteps.wordpress.com\/2016\/10\/23\/foolproof\/\"><a href=\"https:\/\/firstprogrammingsteps.wordpress.com\">Hackerman&amp;#039;s house<\/a><\/a><\/em><br \/><\/p>\n<p>It is usual that the programms that we use in our daily life require the interaction of the people, in this case there are occasions that an input is required to be given by the user, but how can the program now that the type of information the user gives can be used to perform a certain action.<\/p>\n<p>A common case is when the program needs an integer to perform a mathematical operation but the user gives a string. In this case we can use a simple function. It is the try\/except.<\/p>\n<p><img class=\"alignnone size-full wp-image-232\" src=\"https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except-loop.jpg?w=736\" alt=\"try except loop.JPG\" srcset=\"https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except-loop.jpg 367w, https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except-loop.jpg?w=150 150w, https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except-loop.jpg?w=300 300w\" sizes=\"(max-width: 367px) 100vw, 367px\"   \/><\/p>\n<p>In this program, if a number is given it will be stored as the user input. But if the data given is from other type like a string, it will ask again, and again. This loop will make sure that the user gives the correct data.<\/p>\n<p><img class=\"alignnone size-full wp-image-236\" src=\"https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except.jpg?w=736\" alt=\"try-except\" srcset=\"https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except.jpg 594w, https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except.jpg?w=150 150w, https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/10\/try-except.jpg?w=300 300w\" sizes=\"(max-width: 594px) 100vw, 594px\"   \/><\/p>\n<p>Thanks for reading me.<\/p>\n<p>Here is some nice information about this process. <a href=\"http:\/\/www.101computing.net\/number-only\/\" rel=\"nofollow\">http:\/\/www.101computing.net\/number-only\/<\/a><\/p>\n<p><img class=\"alignnone size-full wp-image-90\" src=\"https:\/\/firstprogrammingsteps.files.wordpress.com\/2016\/08\/giphy.gif?w=736\" alt=\"giphy\"   \/><\/p><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/firstprogrammingsteps.wordpress.com\/228\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/firstprogrammingsteps.wordpress.com\/228\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=firstprogrammingsteps.wordpress.com&#038;blog=115170367&%23038;post=228&%23038;subd=firstprogrammingsteps&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Hackerman&amp;#039;s house It is usual that the programms that we use in our daily life require the interaction of the people, in this case there are occasions that an input is required to be given by the user, but how can the program now that the type of information the user gives &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/foolproof\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Foolproof.<\/span><\/a><\/p>\n","protected":false},"author":59,"featured_media":232,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[297,48,24,298],"class_list":["post-38151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-exception","tag-input","tag-python","tag-validate"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38151","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\/59"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=38151"}],"version-history":[{"count":3,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38151\/revisions"}],"predecessor-version":[{"id":38152,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38151\/revisions\/38152"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=38151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=38151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=38151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}