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 clicking here.
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 Quiz III, 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 import math and use the hypot function like this:
>Difference = math.hypot(x1-x2,y1-y2)
For the second problem, we had to do a triangle pattern like those you used to comment on other people’s metroflog. The user submits the maximum number of “T” and the program prints “T” 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:
This was done by defining two functions, the first halve and the second halve, with two for i in range each, one that prints the T in one line and one that controls the flow of the T’s printing per line. One has to use the command end=”” to make sure that the T’s print in the same line. This is the final result, and remember to check my GitHub for a closer look:
For the third part, we had to do
superpower function again (a^b) like in the Second Quiz. But this time I managed to do it with for i in range. This is how:
Finally, Fibonacci… which you can also check out on the Second Quiz blog post!
Now that we are finally done with this, let me tell you about “Here’s to You” by Ennio Morricone & 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.