{"id":655,"date":"2021-03-10T15:45:53","date_gmt":"2021-03-10T15:45:53","guid":{"rendered":"https:\/\/cas.cybercop-training.ch\/?page_id=655"},"modified":"2021-03-10T16:01:54","modified_gmt":"2021-03-10T16:01:54","slug":"a4-mapping-pseudocode","status":"publish","type":"page","link":"https:\/\/cas.cybercop-training.ch\/index.php\/a4-mapping-pseudocode\/","title":{"rendered":"A4: Mapping Pseudocode"},"content":{"rendered":"<h1>Assignment Series A4# Journeyman\u2019s Piece<\/h1>\n<p><img decoding=\"async\" src=\"https:\/\/cas.cybercop-training.ch\/wp-content\/uploads\/2021\/03\/python01.png\" alt=\"\" \/><\/p>\n<h2>Part 1 &#8211; Map Pseudocode to Pythoncode<\/h2>\n<p>I&#8217;m not really familiar with a programming language yet, but I&#8217;ll try to go ahead with python!<\/p>\n<p>Pseudocode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">constant input = [2, 4, 9, 1, 7]\r\n\r\nvariable result = 0\r\nvariable counter = 0\r\n\r\nloop\r\n    exit if counter == input . length\r\n    result = result + input [ counter ]\r\n    counter ++\r\n end loop<\/pre>\n<p>Pythoncode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">input = [2,4,9,1,7]\r\n\r\nresult = 0\r\ncounter = 0\r\n\r\nwhile counter &lt; len(input):\r\n    result = result + input[counter]\r\n    counter+ = 1<\/pre>\n<p>Pseudocode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">constant shapeCorners = { \"Triangle\": 3, \"Rectangle\": 4, \"Pentagon\": 5, \"Hexagon\": 6, \"Heptagon\": 7, \"Octagon\": 8 }\r\n\r\nconstant input = [\"Triangle\", \"Hexagon\", \"Octagon\"]\r\n\r\nvariable result = 0\r\nvariable counter = 0\r\n\r\nloop\r\n    exit if counter == input . length\r\n    result = result + shapeCorners [ input [ counter ]]\r\n    counter ++\r\nend loop<\/pre>\n<p>Pythoncode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">shapeCorners = {\"Triangle\": 3, \"Rectangle\": 4, \"Pentagon\": 5, \"Hexagon\": 6, \"Heptagon\": 7, \"Oktagon\": 8 }\r\n\r\ninput = [\"Triangle\", \"Hexagon\", \"Ocatagon\"]\r\n\r\nresult = 0\r\ncounter = 0\r\n\r\nwhile counter != len(input):\r\n    result= result + shapeCorners[input[counter]]\r\n    counter = counter+1<\/pre>\n<p>Pseudocode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">method addShapeCorners = ( input ) =&gt; {\r\n    constant shapeCorners = { \"Triangle\": 3, \"Rectangle\": 4, \"Pentagon\": 5, \"Hexagon\": 6,\r\n        \"Heptagon\": 7, \"Octagon\": 8 }\r\n    variable result = 0\r\n    variable counter = 0\r\n\r\n    loop\r\n        exit if counter == input . length\r\n        result = result + shapeCorners [ input [ counter ]]\r\n        counter ++\r\n    end loop\r\nreturn result\r\n}<\/pre>\n<p>Pseudocode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">method calculateFactorialInteractive = () =&gt; {\r\n    print (\" Please enter a number : \")\r\n    constant input = read ();\r\n    print (\" The factorial of \" + input + \" is \" + calculateFactorial ( read ()));\r\n}<\/pre>\n<p>Pythoncode:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#Method\r\ndef calculateFactorial(input_factorial):\r\n    result_cf = 1\r\n    counter_cf = 1\r\n\r\n    while counter_cf &lt;= input_factorial:\r\n        result_cf = result_cf * counter_cf\r\n        counter_cf = counter_cf+1\r\n    return result_cf   \r\n\r\ndef calculateFactorialInteractive():\r\n    print(\"Please enter a number:\")\r\n    input_number =  input()\r\n    input_number = int(input_number)\r\n    print(\"The factorial of \" , input_number, \"is \",  calculateFactorial(input_number))<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Assignment Series A4# Journeyman\u2019s Piece Part 1 &#8211; Map Pseudocode to Pythoncode I&#8217;m not really familiar with a programming language yet, but I&#8217;ll try to go ahead with python! Pseudocode: constant input = [2, 4, 9, 1, 7] variable result = 0 variable counter = 0 loop exit if counter == input . length result [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-655","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages\/655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/comments?post=655"}],"version-history":[{"count":6,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages\/655\/revisions"}],"predecessor-version":[{"id":673,"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/pages\/655\/revisions\/673"}],"wp:attachment":[{"href":"https:\/\/cas.cybercop-training.ch\/index.php\/wp-json\/wp\/v2\/media?parent=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}