Ok now, moving on…
Esta parte la haré en español porque creo que podré expresarme mejor. Este curso fue muy diferente a todos los cursos de las otras materias, en el video doy una idea general, y con diferente me refiero a que es un curso en el que puedes demostrar tus habilidades de autoaprendizaje, y yo lo vi más como un reto para darte cuenta si realmente te gusta la materia entonces vas a buscar información para realizar las tareas y quizes. Aunque también fue un poco difícil porque es la única materia con esta “modalidad” entonces algunas cosas las dejé de último momento, como esta, pero de verdad disfruté mucho el curso y espero que el video les agrade.
Aquí dejo una lista de lo que aprendí en el semestre en python:
And here are all my codes for all the wsq’s and quizes since I was missing some of them.
Thanks for all Ken!!
]]>
In mathematics, the dot product, or scalar product (or sometimes inner product in the
context of Euclidean space), is an algebraic operation that takes two equal-length
sequences of numbers (usually coordinate vectors) and returns a single number.
Algebraically, it is the sum of the products of the corresponding entries of the two
sequences of numbers
Create a function called dot_product that receives two lists of numbers (say list1 and
list2). The function returns what is the dot product of the two lists.
For full marks, if the lists are not the same size, then the function should return the
special value of NaN (which represents not a number).
Example. If the input is [2,4,5,6] and [1,2,3,4] the result will be 49 since (2*1)+(4*2)+(5*3)+(6*4) = 49
So this was me trying to do this quiz
**Thanks to this program we can make the product of two lists, it’s very simple, you only multiply each number of the list one by one, but as always in life, there’s one exception, if the size of the list is not equal, then you can’t make the product of the lists, so we have to make a conditional that makes sure to compare the size of the lists and it tells you if there are equals or not, to know the size of the list we can use len.
So here’s the screenshot of the program
And the link in GitHub
]]>This was my face when I realized I was missing Quiz #4 too:
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.
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).
So when I finished reading this, my face was just like WTH is this, so I did my research and I found some interesting stuff, because I didn’t understand a thing about this quiz haha.
In order to understand a little bit more of this number you can check this link out, it explains perfectly what this number is about, so you can do your program better,and one way to know if the program is working correctly is knowing that the maximum value of the e number is:2.71828…so basically the user have to give you the parameter and the program will stop when this is between 2 numbers I think :S.
So here’s the screenshot of the program and the code in GitHub
]]>In this program we reuse the concepts of the code, using “Fun with Numbers”but the only and huge difference is that we have to make a function, ok, this funciotn get 2 inter values, to begin with the program I declare 5 functions which are called: suma, multiplicación, división y residuo.
So here’s the screenshot of the program and the terminal:
And the code in GitHub
]]>
1.-Escribe el función distancia cual recibe 4 números (x1, y1, x2, y2) cuales representan dos puntos en espacio (x1,y1) y (x2,y2). El método debe regresar la distancia entre los dos puntos. Recuerda que el valor cuadrada del hipotenusa del triangulo es igual que la suma de las cuadradas de los otro dos lados del triangulo (the hypotenuse squared is equal to the sum of the squares of the other two sides).
This one was a very easy actually, so here’s the screenshot of the program
2.-(5 puntos) Escribe un función que se llama triangulo cual recibe un parámetro size y imprime un triangulo derecho como el siguiente. El renglón mas grande debe llevar size numero de “T”. SOLO imprime los “T”s y los endlines. Nota que no hay characteres (espacios) a la derecha de los T’s. Debe usar un ciclo “for” para controlar el repetición. Ejemplo es si size era 6.
Here’s number two:
3.-Escribe un función que se llama superpower(a,b) con dos parameters de (enteros / int). Debe regresar el valor del primer parametro al poder del segundo, o mejor decir a b . No puedes usar un función de modulos de Python para hacerlo directo, pero con un ciclo usando multiplicación. Ejemplos: superpower(4,2) es 16 superpower(3,4) es 81:
(5 puntos) Escribe un función que se llama fibonacci cual recibe como parametro un entero no negativo (int) “n” y regresa un entero cual representa el numero en la serie de fibonacci en posicion n. La definición (modificado) del serie de Fibonacci para hoy es: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 ……….. Entonces fibonacci(0) es 0, fibonacci(5) es 5, fibonacci(8) es 21, fibonacci(10) es 55.
And all the codes in GitHub
]]>
Ok here’s Wsq12:
Create a program that asks the user for a word which will be your search word and the name of a file to open and search for that word. Then create a function that will receive two parameters (both string) representing those two data points. This function returns the number of occurrences of that word in that file.
You will need to open a file and read the text line by line. This is straight forward in Python since you can treat the file as a list of lines (strings) and iterate over that using a for loop. Check the section “Looping over a file object” in this link for an idea but your book also has this information
The link that Ken provide us was very useful, you should check it out
Also this link help me to understand a little bit more of this files thing in python.
Here are the screenshots of the program and terminal and the code in GitHub as well.
So I hope you can use this, and see you well read you soon!!
]]>
Your jobs is to create a program that asks the user for two pieces of data:
Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.
Wow, Ken si que se esforzó en complicarnos un poco la vida jaja, primero que nada tenemos que entender que es un número Lychrel y este link fue de gran ayuda.
Para entender un poco mejor que era lo que necesitábamos hacer realmente en el programa el video de Ken fue de gran ayuda, y lo dejo aquí por si alguien no lo ha visto.
Y después de varios intentos fallidos, el programa funcionó correctamente, o al menos eso creo. Aquí están los screenshots :
the second part and the terminal:
and the code un GitHub
Create a program that asks the user for 10 numbers (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.
What?? standard deviation?? What the hell is that?? well, here’s the answer, this page was very helpful because it explains how the standard deviation works, and it gives you examples on how to do it, so you can apply those examples for the program.
Well knowing that, now we can focus in the point of this wsq, which is put the 10 numbers given by the user, in lists, and return the sum, average and standard deviation of the 10 numbers. If you want to know a little bit more about lists you can consult this link, it has many many examples of lists, it’s a very long document, but you can read it if you’re interested: https://docs.python.org/3/tutorial/datastructures.html
But thanks to Danny and his link about lists, was easier to do this program, so thanks Danny.
Well here’s the program and the screenshots of the terminal:
You can notice that I used the module statistics which made this wsq so much easier, this module allow us to use statistics functions.
Here’s the code on GitHub
]]>Ok, I just realized that Ken loves palindromes!! haha jk Ken, ok so basically is all explained there, we have to make a program to tell us if a word is a palindrome or not, and it doesn’t matter what characters does the word have, or capital or lower case , as long as it say the same backwards.
In class told us some tricks to make this quiz, and there were very helpful.
Here’s the code:
here’s the second part:
And as usual the code in GitHub
]]>
The function should receive two integers and return an integer.Obviously you should test your function, so create a main program that asks the user for two values, calculates the gcd and displays that.
Al leer de que se trataba este algoritmo de Euclid’s gracias a la información proporcionada por Ken, no puede evitar pensar que con esto resolveríamos los problemas que tiene algunos con las fracciones jaja.
Pero en fin, aquí está el programa:
And the link at GitHub
]]>