#QUIZ04

 Quiz 4

TC101 (Python Group)

Remember that this will not be graded but you should keep this sheet and your solutions as evidence of work. Email your answers to Ken today (so we keep a record of your code today) and also I recommend you post your code on Github and write on your blog as another blog post evidence.

Use your own computer to write the code. Remember that I trust you and you need to do this honestly to give yourself a good “measure” of your ability to this point. If you complete this later than today, then just complete as quick as you can.

  1. The number e is an important mathematical constant that is the base of the natural logarithm. It is approximately equal to 2.71828,[1] and is the limit of (1 + 1/n)n as n approaches infinity, an expression that arises in the study of compound interest. It can also be calculated as the sum of the infinite series.

e =  displaystylesumlimits_{n = 0}^{ infty} dfrac{1}{n!} = 1 + frac{1}{1} + frac{1}{1cdot 2} + frac{1}{1cdot 2cdot 3} + cdots

         Create a function called euler_calc with a single parameter precision. The value of                  precision is used to determine when to stop calculating. Your calculation will stop                  when the two consecutive values estimating e differ by less than precision (remember          to use absolute value when calculating the difference between two values here).

En este quiz cree una función que se encarga de realizar el proceso para el numero de             Euler, el programa recibe un valor dado por el usuario que se encarga de detener el                 proceso para determinar el numero.

Como primer paso pedí el valor al usuario para

ELEULER.png

Continue reading “#QUIZ04”

Quiz #6

Hello everyone! Now we have a new quiz, and we’re supposed to create a program that calculates the greatest common divisor of two integers… pretty easy hahaha

We’re going to ask the user to give those values (obviously integers because… I don’t know, integers rules!) and the program will calculate the greatest common divisor using the Euclid’s algorithm. Now what the… is the Euclid’s algorithm?? Here you can see what it is…

Captura de pantalla 2016-04-04 a las 7.59.51 p.m.

Now let’s create the program. The function called MasterAguayo is where the magic happens. It takes two values and by using ‘if statements’ we are switching the numbers using modules and all that stuff. 

Captura de pantalla 2016-04-04 a las 8.08.34 p.m.

It is pretty easy to understand this algorithm and you’re supposed to know how it works if you’re at college… if that’s not the case, well don’t worry because there is a lot of information available on the web. 

Here is my code via GitHub. You can check it out and feel free to do whatever you want with it. 

Alex H.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

Quiz #5

Hello everybody, I know that I hadn’t posted anything for a while but I’m back! With all the homework and projects, I didn’t have time to upload my codes even I had them on my computer. So heres is the Quiz #5.

Basically, we are asked to create two programs: the first one is supposed to read a string and determine if it is a palindrome or not. It’s like #YoSoy196 but this one with words. Even though I haven’t done the #YoSoy196 because there are some things that I’m not understanding, here is my code for the first program. Captura de pantalla 2016-03-22 a las 12.26.42 p.m..png

As you can see, now we’re only working with boolean expressions. The options are just ‘It is a palindrome’ or ‘It is not a palindrome’. So in the main function we receive our word, which it is a string.  Then our function called esPalindromo just compare our string and determine if it’s palindrome or not.

Here is my code on GitHub. LINK

Now, the second program had to print the addition of numbers divisible by 3. The user would type some values and the program had to determine which ones were divisible by 3 and add them. And here is the code for the second program. LINK2

Captura de pantalla 2016-03-22 a las 12.34.16 p.m.

24294566811_7004231734_k
Another Sunrise over the Alps by Rogg4n Link on Flickr: https://www.flickr.com/photos/128294308@N05/24294566811/in/explore-2016-01-14/

 

Quiz #4

Here is my Quiz #4. First, let’s read the instructions:

Captura de pantalla 2016-04-04 a las 7.32.09 p.m..png

Basically we have to create a program that calculate the euler number, which as you can see it is an important mathematical constant. The user will give the precision wanted and the program should stop working when the last two values differ by less than the precision given by the user.

First, we create a function that calculate the factorial series from the number 1. We will use this function later when we want to calculate the algorithm of the euler number.

Captura de pantalla 2016-04-04 a las 7.35.56 p.m.

Captura de pantalla 2016-04-04 a las 7.42.51 p.m.

For this program Ken helped us in class because we had no idea of what we were doing… we created a program that showed us the multiple values of euler for a given number and that helped us to understand about setting the precision. 

Here you can see the actual code of the Quiz on GitHub.

Aaaaaand here you can see the code for the different values of e for a given number. It can help you to understand the whole question of the quiz.

Peace…

Alex H.

#Quiz3

 Quiz 3

TC101 (Python TC1014 edition)

Remember that this will not be graded but you should keep this sheet and your solutions as evidence of work. Email your answers to Ken today (so we keep a record of your code today) and also I recommend you post your code on Github and write on your blog as another blog post evidence. Use your own computer to write the code. Remember that I trust you and you need to do this honestly to give yourself a good “measure” of your ability to this point.

  1. Write a function called distance(x1, y1, x2, y2) which receives four numbers which represent two points in the cartesian plane. The function should return the distance between the two points (x1,y1) and (x2,y2). Remember that the square of the hypotenuse of a right angle triangle is equal to the sum of the squares of the two other sides

Este fue el ultimo Quiz del parcial, en este penúltimo problema había que hacer una función que calculara la distancia entre dos puntos, para lograrlo solamente declare la función y especifique la formula para calcular la distancia entre dos puntos, eso si, para usar la raíz cuadrada necesaria en la formula, hubo que importar un modulo que se llama math y lo utilice de la siguiente manera:

variable=math.sqrt(a lo que se le quiere sacar raíz)

Al final se llama a la funcion y se le dan los parametros, en este caso al imprimir la función utilice el comando round(valor,espaciosdecimales) para quitar los excesivos decimales que arroja python.

Aquí esta el código.

import math
print(“Este programa te da la distancia entre dos puntos”)

def distancia (x1,y1,x2,y2):

result=math.sqrt((x2-x1)**2+(y2-y1)**2)
return result

dis=distancia(3,2,5,6)
print(round(dis,2

ya casi.png
yamero

Continue reading “#Quiz3”

#QUIZ01

Quiz 1 

TC101 (Python TC1014 edition)

Remember that this will not be graded but you should keep this sheet and your solutions as evidence of work. Email your answers to Ken today (so we keep a record of your code today) and also I recommend you post your code on Github and/or your blog as another blog post for this quiz.

Use your own computer to write the code. Remember that I trust you and you need to do this honestly to give yourself a good “measure” of your ability to this point.

  1. Create a file called prog1.py Write a program that asks the user for two values (radius, height) of type float and returns the volume (V = ¶ r2 * h) of a cylinder with that radius/height as a float

Quiz #3

So this was the Quiz #3, and here you can see what I was supposed to do. First, create a program that calculate the distance between two points given by the user, in the cartesian plane. And the second one, was to create a program that could show you the fibonacci series of a number that was given.Captura de pantalla 2016-02-12 a las 23.24.10.png

For the first problem, you had to calculate the middle point of the two values for “x” and for “y”, then you had to apply the Pythagorean theorem in order to calculate the distance. As you can see for the value of “x” I used a variable called “a” and for the “y” value I used a variable called “b”. After you had the difference between those values (x2-x1 and y2-y1) you must use the Pythagorean theorem and that’s it. Then you had to call the distance function into the main function.

Here you can have a look of this code on GitHub. Captura de pantalla 2016-02-12 a las 18.36.04

For the second program, I worked with my friend Dario. (check out his blog HERE, he has an awesome blog). We tried to understand first the Fibonacci series and then we had to apply it to the code. We spent the rest of the class trying so many ways that we ended up stressed and pissed off with the whole world hahaha. After a few hours I gave it a second chance to this program and I searched for any information that could help me with this problem. I found this article that gave an idea of the structure of the program.

http://code.runnable.com/UqfN-4zVBhVwAAH9/solving-the-fibonacci-number-sequence-using-recursion-in-c%2B%2B-for-recursive

Here you can have a look of this code on GitHub. Captura de pantalla 2016-02-12 a las 18.35.41.png

And when the second program finally worked, I was like… #youknowthatfeel

jixctemu5rcpo

Thanks for reading! Peace…

5nczoumgibjzo

Alex H.

24294566811_7004231734_k
Another Sunrise over the

Continue reading “Quiz #3”

Quiz #2

Now, I’m going to talk about how I wrote my codes for the Quiz #2. First, let’s check out the instructions:
Captura de pantalla 2016-02-11 a las 17.55.39

I started with the first program and it took me the whole class because I was having problems with the structure of the code. I asked my friend Dario to help me and he told me what I had wrong. Thanks m8. You can visit his blog here, he has a lot of cool stuff there. He is Dario, in case you didn’t know him hahaha.

djafj.jpg

So here is the code for my first program…

As you can see, I created a function called “superpower” and inside the function I put a loop, so I could raise the first parameter to the second one. This loop would keep working if the value of d was different from the second number.

Captura de pantalla 2016-02-11 a las 18.11.56.png

Once I figured it out that part, I wrote the main function and just called the superpower function when I was supposed to give the answer. I used another loop just to let the user try with different numbers.

 

And for the second program was easier. For this one, the user had to type a number “n” and then the program had to display “n” times the character ‘*’. I created a function called “stars” and put a loop which only write “*” times as the user asked for. Then, in the main function I just called the “stars” function as the answer. This one was easier though.

Captura de pantalla 2016-02-11 a las 18.20.35.png

I’m feeling lazy right now so this time I won’t be uploading a video of my codes working, but you can check them out on GitHub.The files are called “pro1Quiz2.cpp and pro2Quiz2.cpp”. Here is the link. Feel free to comment or try them on your own way.

5nczoumgibjzo
24294566811_7004231734_k

Continue reading “Quiz #2”

Quiz #1

My first quiz… Let’s start reading what I was supposed to do… 

Captura de pantalla 2016-02-09 a las 11.50.01.png

I had some trouble trying to get the value of π, I did some research and I needed the <cmath> library because I was going to need the value of π. As you are using the cmath library, π is declared as M_PI so you just have to type that when you will use π.  After that, the rest of the program was very simple.

Here is how I wrote my code for the program #1. 

Captura de pantalla 2016-02-09 a las 12.08.02.png

The next program was pretty easy. I was asked to write a program which the user could type two numbers and the program would show the product of the two numbers, the division and the remainder from the division of the two numbers. You shouldn’t have any problem writing this code. Here is how I wrote the program #2.

Captura de pantalla 2016-02-09 a las 12.11.35

And finally, for the last program the only thing that you needed to change was the data type from int to float. You wouldn’t have a remainder from the division, you only were supposed to show the addition, product, subtraction and division of the two float numbers. Here is how I wrote my code for program #3.

Captura de pantalla 2016-02-09 a las 12.17.21.png

Here you can see my codes on GitHub. And here you can see my code working via ScreenCast.

Captura de pantalla 2016-02-09 a las 12.37.48.png