WSQ10 ‘Lists’

 

For this one, we were in charge of letting the user sumbit 10 numbers and play with them. The point of this WSQ was to append the 10 numbers that the user sumbits to a list, and us to program different operations with those numbers. In this WSQ, I learned a bunch of codes and strategies. For example:

  • x = [] has to be empty in order to let the user fill the x with the 10 digits he submits.
  • x.append(float(input)) so the program fills x with the digits.
  • import statistics so I am able to use statistics functions since the WSQ requested standar deviation. This is easier than to search for the formula and manually code it.

bulbasaur

At any case this is how the code looks and runs , and here is the GitHub to analyse it closer. I made the comparision with a random webpage to double check it was correct.

WSQ10.png

This blog is sponsored (I wish) by Jack Dolgen’s “I Will Come For You”. As part of How I Met You Mother’s soundtrack, this song is full of feelings. This song is played during one of the saddest moments of the show, episode 19 of season 6. A kid needs a hoop…

I will come for you.png

 

Quiz 04 Euler number

If x  = 5, what is the mass of the sun? escalated.jpg

That same reaction was what I had when I got in charge of doing Quiz 04. This time we had to make the sum of 1 divided by n! factorial. This until it reaches the euler number = 2.71 and it stops looping around.

quiz04.png

I broke my head constantly for several days trying to reach the answer for this equation in python3 language. This was until Ken Bauer miraculously helped me out and teached me what means each step means. I am not trying to pass the course by copy pasting codes. It is just that I have to see what is happening in a code first and then analyse it. This is in order to learn what to do and use it for future references. For instance, from the previous WSQ09 i learned to do factorials, so that was a piece of cake in this quiz. This is the code:

quiz04code

And this is how it runs:

quiz04run

When n! is 18 and n! is 19, the answer it is the same. That moment it is when it stops.

I am going to introduce another David Bowie’s song over here just for one reason, maybe a slowpoke one since I just realized it. This one is called Lazarus. It was released in his most recent album Blackstar in 2016. This song got his video release 3 days before he passed away in January 10th 2016. It is a really sad song. Was he saying goodbye? Who knows, but it gives this song even a bigger meaning. May he rest in peace.

lazarus.png

 

 

WSQ09 Factorials!

This time we have to do factorials. This means n! = (n)(n-1)(n-2)…(1). Multiply n times the previous number until it reaches 1.

For this I used a for in range (1, x + 1) . When x is the value that the user inputs. The, y = y*i so it keeps repeating itself until it becomes 1. Secondly I used conditionals to predict the parameters when x is 0 or when x is a negative, so the program gives the obvious.

Finally, I took a peek at my classmates’s blog to learn what to do in order to let the user try again or exit the program. Thanks to Pxthon Progrxmmer I learned that you can use a while True to make the whole conditionals and the factorial formula work and when it ends let the user try again by typing ‘a’ or exit by typing a different letter.

wsq009.png

Today’s song is ‘Short Change Hero’ by The Heavy. A song that is used at the intro of Borderlands 2 when introducing the main characters. It is an epic way to show the players what they will meet in the world of Pandora because Pandora “ain’t no place for no hero”.

short change hero

Partial Exam

partial1reaperToday the partial exame was given to us. They were all open questions to explain what you’ve learned so far. Remember that this is a prototype class for #AbolishGrade so it is not that drastic. That means that it is just to follow us on the process of learning; however, it is okay if you fail to answer the exam.

The first partial exam came in a format like this:

Firstpartialexam

Blog under construction… 

 

 

Quiz III

Brace yourselves, the partial is coming. Meanwhile, we have to answer a third quiz.

quiz3instructions.png

At the first point we had to find the distance between two points. If you represent this as an a triangle, it would be like Image 1 where A is (x1,y1) and B is (x2,y2), so we had to find the value of h.

2000px-trigonometry_triangle-svg
Image 1

At first I tried to find the distance between each axis. This means what is the difference of x1 and x2 and what is the difference between y1 and y2. This got complicated to me since distance is absolute, yet the answer was given as negative in some occasions. This got fixed when I used a conditional to multiply it by -1 to make it positive.

 

Then I got to the point to find h. I used the basic pythagoras theorem (C^2=A^2+B^2)  and then use the squareroot to get the answer. Ken teached me that there was a simplier way: use the distance command. Yet, It have me errors when running so I kept it at my mode since it works. Of course this does not means I am not going to fix what Ken helped me with. The code and how it runs looks like this:

pythagoras

For the second part of the quiz I had  a big time learning what to do. Firstly because I did not even know what the Fibonacci Numbers are. After I knew what they are, I searched all over the internet to see how to do it. Technobeans showed me 5 different methods of how to do it; however, Naren’s method in the comments helped me better.

fabonacci

Remember to keep checking my GitHub to see the code clearer.

Time for you to meet Bloc Party’s “Helicopter”. I got into this band because of

helicopter

Continue reading “Quiz III”

WSQ08 ‘WSQ03 Version 2.0’

This ‘On To Functions’ WSQ is kinda weird. The instructions were the same as WSQ03 with only one difference: Separating the operations from the answer’s printing.

This is how WSQ03 looked like. And this is how it changed:

WSQ08code

It still runs the same in case you were wondering.

WSQ08run

This may be a short post, but the reason is that the changes were minimal. Well then, lets talk about a classic. “The Man Who Sold The World” by David Bowie. Not so long ago, this same man passed away. I always knew about this classic; however, I got the interest into it because of Metal Gear Solid V: The Phantom Pain. Even so it is a cover of this song, the lyrics match what ‘Venom Snake’ is going through. David Bowie gave this song a meaning of existentialism  because he portraits his two selves: the image he sold to the world and the his true self negating each other.

The Man who sold the world

WSQ07 ‘Sum of Numbers’

Ever wondered what is the result of the addition of all the intergers from a certain range? Of course not, but let’s calculate it!

okami doge
Sorry, been playing Okami lately. 

What I mean by ‘Sum of Numbers’, it is for example: from a range of 5 to 10 one has to sum 5 + 6+ 7 + 8 + 9 + 10. This has to be done in order to get the final result of 45.  Sounds easy right? But what if the range was bigger? For example from 1 to 100. One is not going to grab a calculator and start “1+2+3+4+5+6+7+8+9+(…)+100”. Of course not! This is why I was in charge of programming a code were the computer automatically does this.

 

 

I will be using the classic variables “x” and “y” to define the range. This time “x” is the number we begin, and “y” is the number the addition countdown stops. However, I had to make a prediction were the user actually submits “x” higher than “y”. This would me impossible since the program is unable to count backwards. So I used a conditional “If” to let the user know what the mistake is. In the end, this is my code.

WSQ07 code

Looks cool right? It looks better when one uses it.

wsq07run

This blog corresponds to the song “After Midnight” by Blin182. I am not that old, yet I know that band brings nostalgia to most of the 90’s kids. This song was recommended by an old friend of mine, and I have must say thanks to her for introducing me this awesome song.

After Midnight

 

WSQ06 Guess my number

 

picture079
Hello user. I want to play a game.

I am thinking of a number from 1 to 100, and it is not a decimal. Guess it or Game Over!

 

 

 

 

For this WSQ06 we had to program the system to take a number from the range 1 to 100. At this case we have to use the function rand_num and make it interger with randint(1,100) . The main point at this program is to play the “warm or cold” game where you give the player the clue that his guess was higher or lower than the actual number.

This is were one uses the conditionals if and elif, so one predicts all the possible answers from the user. If guess is higher than random number then it prints that the guess is higher. And viceverse if the number is lower.

At first I had troubles printing the “You win!” screen message.
randomnum question

Then I noticed that the last “elif” has to be written as “else” since it is the last option from the conditionals. This is without the actual condition “==”. Also, there was a problem with the indent since “else” has to match the “while” position. Like this:

wsq06 win.png

I did not used a conditional if the user tries a number higher than 100. This is because the program will tell the user to try a lower number. Everything is ready to go. Now let’s play!

wsq06 win

The WSQ06 is over, but I challenge myself to learn how to tell the user’s tries and to limit the game to an actual number of tries. This is in order to make a “Game Over” screen possible.

Today’s blog corresponds to the song “Swing Life Away” by Rise Against. No,  not Rage Against the Machine but Rise Against.  A song

swing life away

Continue reading “WSQ06 Guess my number”

Second Quiz

Another class, another quiz.

This time we were in charge of making loops. However, since I found out a the easy way, I used those methods.

For the first part we were in charge of ‘a’ be at ‘b’ power. In Python 3 this operatios is represented with “**”. So the code looks somehow like this:

quizpower.png

Then the second question requested us to print “*” a certain number of times in the same line. Even so it was forbidden, I used multipications to print x number of times the symbol “*”. Yet, I could not find out a way to print it at the same line. Still in the process of exploring other people’s blogs to see the other way to do this two exercises and to find out how to print in the same line.

Here code for part 2:

printstars.png

And this is how it runs!

printstars.png

WSQ05 Temperature

There comes a moment in one’s carrer, mostly engineers, where there is a given temperature in Fahrenheit, but one has to convert it to Celsius. Rather than looking for the particular formula, which is  C = 5 ∗ (F − 32)/9, one prefers to use a direct converter. For this assignment Ricardo will be programming one to help others carry out their laziness at work.

rayquaza

The first part of the program was basic. It’s just defining x which the user defines according to the Temperature in Fahrenheit that the user wants to conver. After that, using the equation previously mentioned, the program converts the amount given into Celsius. Success!

temperatura

The can of worms over here was the conditional ‘If’ since Ricardo never succeeded to submit it correctly. The assignment gave the instruction to program wheter or not the water boils at the temperature given by the user. After researching on Google, it is known that water boils at 212 F° or 100 C°