{"id":33206,"date":"2016-02-20T00:18:43","date_gmt":"2016-02-20T06:18:43","guid":{"rendered":"http:\/\/alextenablog.wordpress.com\/?p=369"},"modified":"2016-02-20T01:01:28","modified_gmt":"2016-02-20T07:01:28","slug":"wsq09-4","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/02\/wsq09-4\/","title":{"rendered":"#WSQ09"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\" aligncenter\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/e7395eeaed8e21a659d0f1cc4f0fcff4.jpg\" alt=\"\" width=\"448\" height=\"254\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>For this assignment we needed to make a factorial calculator. The factorial of a number is the multiplication of all numbers that are lesser than that number until 0. For example the factorial of 4 is equal 4x3x2x1=24<\/p>\n<p>This program required loops as we couldnt use the default python function from the math module.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>-So first I used while loop so the user can use the program as many times he like.\u00a0<\/strong><\/p>\n<p><em>res=&#8221;x&#8221;<\/em><br \/>\n<em>while (str (res) != &#8220;n&#8221;):<\/em><br \/>\n<em> print (&#8220;This program is a factorial calculator&#8221;)<\/em><br \/>\n<em> n= int (input (&#8220;Please give me a positive integer number: &#8220;))<\/em><em><img decoding=\"async\" class=\" alignright\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/4dd12de34e20d660e0b09ac2a779720b.jpg\" alt=\"\" \/><\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>-Then I implemented a for loop in order to calculate the factorial of any given\u00a0number.\u00a0<\/strong><\/p>\n<p><em>for n in range (1,n+1):<\/em><br \/>\n<em> num= num*n<\/em><br \/>\n<em> print(&#8220;The factorial of the given number is: &#8220;,num)<\/em><br \/>\n<em> print (&#8220;&#8221;)<\/em><br \/>\n<em> print (&#8220;y= yes, n= no&#8221;)<\/em><br \/>\n<em> res=str(input(&#8220;You wish to calculate another factorial of a number? &#8220;))<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>-And finally I used an If so my loop could work as I wanted.<br \/>\n<\/strong><\/p>\n<p><em>if (res==&#8221;n&#8221;):<\/em><br \/>\n<em> print(&#8220;&#8221;)<\/em><br \/>\n<em> print(&#8220;Have a nice day!&#8221;)<\/em><br \/>\n<em> else:<\/em><br \/>\n<em> print(&#8220;&#8221;)<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>The final code:<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-388\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/c4550a041747400d33d83b7e39303354.jpg#038;h=358\" alt=\"fac\" width=\"708\" height=\"358\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>The program:<\/strong><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-391\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/2b94685116a79d75053eb80913f7130a.jpg\" alt=\"fac2\"   \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" aligncenter\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/a13c402a7e75fdf5ad46663523768bbf.jpg\" alt=\"\" width=\"229\" height=\"168\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Btw, I\u00b4m not sure if I completely understand how indentation works on python and on my Text editor.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" alignright\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/c7a563b7516dfe15e1454499ca0a0633.jpg\" alt=\"\" width=\"402\" height=\"189\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/alextenablog.wordpress.com\/369\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/3b9663608c4b1d6fd69f26648422a718.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/666eb23c74b45c44a7876f486b9deba1.jpg#038;blog=105328326&#038;%23038;post=369&#038;%23038;subd=alextenablog&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; For this assignment we needed to make a factorial calculator. The factorial of a number is the multiplication of all numbers that are lesser than that number until 0. For example the factorial of 4 is equal 4x3x2x1=24 This program required loops as we couldnt use the default python function from the math module. &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/02\/wsq09-4\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">#WSQ09<\/span><\/a><\/p>\n","protected":false},"author":46,"featured_media":33214,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[127,45],"class_list":["post-33206","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-wsq09","tag-sin-categoria"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/33206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=33206"}],"version-history":[{"count":3,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/33206\/revisions"}],"predecessor-version":[{"id":33227,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/33206\/revisions\/33227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/33214"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=33206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=33206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=33206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}