{"id":36277,"date":"2016-04-18T09:23:59","date_gmt":"2016-04-18T14:23:59","guid":{"rendered":"http:\/\/rhcpalmarichiewordpresscom.wordpress.com\/?p=566"},"modified":"2016-04-18T09:59:13","modified_gmt":"2016-04-18T14:59:13","slug":"wsq13-second-partial-exam","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/04\/wsq13-second-partial-exam\/","title":{"rendered":"WSQ13 \u2018Second Partial Exam\u2019"},"content":{"rendered":"<p>We finally reached the end of the second partial and, with it, the second partial of this course. It was similar to the previous exam; however, we had to make four different programs. They were easy, yet I could only make one work correctly since the other three gave me an error I could not fix. You can check the exam problems by <a href=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/Programming_TC1014_Exam02.pdf\">clicking here<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-571\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/044fddf9c3ccf924108ec33c097466aa.jpg#038;h=438\" alt=\"partialiimeme.png\" width=\"288\" height=\"438\" \/><\/p>\n<p>The first part of the exam was to find the distance between two points: P1(x1,y1) and P2(x2,y2). This seems familiar right? It is because I have done it before in <a href=\"https:\/\/rhcpalmarichiewordpresscom.wordpress.com\/2016\/02\/18\/quiz-iii\/\">Quiz III<\/a>, so you can click on the link to take a loot at that blog post. However, there is a simplier method for this. One can\u00a0<strong>import<\/strong> math and use the hypot function like this:<\/p>\n<p style=\"padding-left:30px;\"><code><br \/>\ndef Distance(x1,y1):<br \/>\n&gt;Difference = math.hypot(x1-x2,y1-y2)<br \/>\n&gt;return Difference<br \/>\n<\/code><\/p>\n<p>For the second problem, we had to do a triangle pattern like those you used to comment on other people&#8217;s metroflog. The user submits the maximum number of &#8220;T&#8221;\u00a0and the program prints &#8220;T&#8221; starting by one until it reaches such number, and then it goes back to one. For example if the user says the maximum is 4 then the pattern will be like this:<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<br \/>\nT<br \/>\nTT<br \/>\nTTT<br \/>\nTTTT<br \/>\nTTT<br \/>\nTT<br \/>\nT<\/p>\n<p>This was done by defining two functions, the first halve and the second halve, with two\u00a0<strong>for\u00a0<\/strong>i\u00a0<strong>in rang<\/strong><strong>e\u00a0<\/strong>each, one that prints the T in one line and one that controls the flow of the T&#8217;s printing per line. One has to use the command\u00a0<strong>end=&#8221;&#8221;<\/strong> to make sure that the T&#8217;s print in the same line. This is the final result, and remember to check my <a href=\"https:\/\/github.com\/RichiePalma\/CoderRichie\/tree\/master\">GitHub<\/a>\u00a0for a closer look:<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-610\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/b23f694b9dabb16ea6d86b4ff234fb84.jpg\" alt=\"Triangulo\"   \/><\/p>\n<p>For the third part, we had to do <\/p>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-622\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/55b3a5d5ca07fe7d8f0e9047d6d07501.jpg\" alt=\"exponent\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-631\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/797b31c0fc7320d93b40bcf6c933c75f.jpg\" alt=\"Here's to you.png\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/30b38f1305fa0dde0128863083d7e155.jpg\" \/><\/div>\n<div class=\"post-limited-image\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/5939c9e8a44dfe501fc322e299adb104.jpg#038;blog=105330260&#038;%23038;post=566&#038;%23038;subd=rhcpalmarichiewordpresscom&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div>\n<p><!--more--> superpower function again (a^b) like in the <a href=\"https:\/\/rhcpalmarichiewordpresscom.wordpress.com\/2016\/02\/06\/second-quiz\/\">Second Quiz<\/a>. But this time I managed to do it with\u00a0<strong>for\u00a0<\/strong>i in\u00a0<strong>range<\/strong>. This is how:<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-622\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/55b3a5d5ca07fe7d8f0e9047d6d07501.jpg\" alt=\"exponent\"   \/><\/p>\n<p>Finally, Fibonacci&#8230; which you can also check out on the <a href=\"https:\/\/rhcpalmarichiewordpresscom.wordpress.com\/2016\/02\/06\/second-quiz\/\">Second Quiz<\/a> blog post!<\/p>\n<p>Now that we are finally done with this, let me tell you about &#8220;Here&#8217;s to You&#8221; by Ennio Morricone &amp; Joan Baez. Both of them have their own separate version, but the one of them together is the best one. This song can tell you how school is going, so far. Just kidding, this is a beautiful song in honor of Nicola Sacco and Bartolomeo Vanzetti. This song can be heard during the trailer of Metal Gear Solid V: Ground Zeroes and also inside the game as a bonus soundtrack.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-631\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/797b31c0fc7320d93b40bcf6c933c75f.jpg\" alt=\"Here's to you.png\"   \/><\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/rhcpalmarichiewordpresscom.wordpress.com\/566\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/30b38f1305fa0dde0128863083d7e155.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/5939c9e8a44dfe501fc322e299adb104.jpg#038;blog=105330260&#038;%23038;post=566&#038;%23038;subd=rhcpalmarichiewordpresscom&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We finally reached the end of the second partial and, with it, the second partial of this course. It was similar to the previous exam; however, we had to make four different programs. They were easy, yet I could only make one work correctly since the other three gave me an error I could not &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/04\/wsq13-second-partial-exam\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">WSQ13 \u2018Second Partial Exam\u2019<\/span><\/a><\/p>\n","protected":false},"author":33,"featured_media":36278,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[124],"class_list":["post-36277","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-ironfromice"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/36277","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\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=36277"}],"version-history":[{"count":5,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/36277\/revisions"}],"predecessor-version":[{"id":36289,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/36277\/revisions\/36289"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/36278"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=36277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=36277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=36277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}