Quiz 07

Here is my blog for the Quiz 07

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). Here is the link to my GitHub.

Captura de pantalla 2016-05-05 a las 12.04.04 a.m..png

Course Review

Me dare la libertad de escribir este blog en español para poder expresarme de una forma más completa.

Quisiera empezar dejando claro que en este curso aprendi muchas cosas de las cuales estoy seguro que van a ser fundamentales a lo largo de mi carrera, las aprendi de una forma u otra, pero en lugar de hacer este blog muy largo y tedioso dare lo que me llevo del curso en general.

Este tipo de curso es muy diferente a los demás, porque aquí tu aprendes bajo tu propia cuenta, si, el Ken va a estar allí contigo para cualquier pregunta que necesites o duda, pero este modelo de curso se basa principalmente en el auto estudio, y en mi opinion personal siento que es algo que enriquece mucho tu aprendizaje y te hace ver los problemas desde una ángulo diferente.

Es una metodología diferente la cual probablemente no estamos preparados en este país, es un curso para las personas entusiastas de aprender y no ser conformistas.

Flipped Classroom Image.jpg

*Me gustaría aclarar que aunque este blog dice que lo subí el día mayo 5, no es así y lo estoy subiendo el 4 de mayo, no se porque hace ese cambio de horario, es igual para mis blogs pasados.

Quiz 05

Here is my blog post to my Quiz 05.

  • Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case). Here is the link for my link to GitHub.

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

  • Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12). Here is my code to GitHub.

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

Quiz 04

Here is the Blog post for my Quiz number 4.

  1. 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). Here is the link to my GitHub.

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

 

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

 

Quiz 03

Here is my blog post for the Quiz 3

  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. Here is the link to my GitHub.

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

 

  1. Write a function called fibonacci which receives a single parameter“n”(anon-negative integer) and returns the nth number in the fibonacci series which is:
    0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89… Here is the link to my GitHub

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

#Quiz07

Quiz 7

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).

  • For Python, you can create this value with the expression: float(‘NaN’)

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

 

Gracias a este programa podemos hacer el producto de dos listas, es muy simple ya que solamente multiplicamos cada numero de la lista uno por uno, pero existía una excepción, que si el tamaño de las listas no eran iguales, entonces no se podría realizar el producto de las listas, para lo que hice un condicional que se encarga de comparar el tamaño de las listas y te dice si son iguales o no, para saber el tamaño de la lista use la función len de no serlo retorna NaN(Not a Number). En este programa utilice por primera vez un ciclo for doble, para realizar la multiplicación de las listas.

Aquí esta mi código:

import os
os.system(“clear”)
print(“scalar product”)
lista1=[1,2,3,4]
lista2=[2,4,5,6]

def dot_product(var1,var2):
acum=0
if(len(var1)==len(var2)):
for l1,l2 in zip(var1,var2):
suma=l1*l2
acum=acum+suma
print(acum)
else:
print(“NaN”)

dot_product(lista1,lista2)

Por aquí el enlace a GitHub

Por acá el programa funcionando:

ESTEYAESTETAMBIEN

 

#QUIZ06

Quiz 6

  1. Write a function to calculate the greatest common denominator of two positive integers using Euclid’s algorithm.

 

print(“Euclid’s algorithm”)

numero1=int(input(“Dame el primer numero: “))
numero2=int(input(“Dame el segundo numero: “))

def gcd (a,b):
if(a==b):
return a
elif (a>b):
return gcd(a-b,b)
else:
return gcd (a,b-a)

resultado=gcd(numero1,numero2)
print(“El maximo comun denominador es:”,resultado)

#QUIZ05

 Quiz 5

TC101 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. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).

En este quiz debíamos crear un programa que detectara si una palabra es un palindromo, o no lo es, ademas para agregarle diversión al programa, debía saber si una palabras es palindromo o no, pero también tenia que ignorar si la palabra tenia mayúsculas o minúsculas, simplemente debía decir si es un palindromo o no dejando de lado símbolos y mayúsculas.

 

  1. Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would

    Continue reading “#QUIZ05”