Commit 23110dd8 authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

update

parent ddb6fbf4
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4 Examen Unidad 1\n",
"Escribe una función o classe y su docstring para los siguientes ejercicios. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.1 Obten el promedio de los numeros en una lista."
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.675\n"
]
}
],
"source": [
"#le damos la lista de numeros a promediar\n",
"lista = [8,2,3,5.7]\n",
"\n",
"#Funcion que lee la lista de numeros y saca el promedio\n",
"def ejercicio1(lista):\n",
" contador=0\n",
" for n in lista:\n",
" contador+=n\n",
" #utilizando la funcion len se obtine la n( cantidad de numeros de la lista ) necesaria para sacar el promedio\n",
" cantidadlista = len(lista)\n",
" # se realiza la division para sacar elpromedio con float entre la n, para obtener decimales.\n",
" return contador/float(cantidadlista)\n",
"\n",
"#Llamamos a la funcion de impresion por consola (print) para que muestre el resultado de llamar a la funcion \"promedio\" con el arreglo \"valores\" como argumento\n",
"print(ejercicio1(lista))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.2 Regresa todos los numeros enteros en una lista dividida por un numero."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Proporcione el numero entre el cual se dividira la lista:\n",
"1\n",
"18.0\n"
]
}
],
"source": [
" \n",
"lista = [8,2,3,5.1]\n",
"print (\"Proporcione el numero entre el cual se dividira la lista:\")\n",
"numero = int (input())\n",
"\n",
"def ejercicio2(lista, numero):\n",
" \n",
" contador=0\n",
" for n in lista:\n",
" contador+=n\n",
" \n",
" \n",
" # se realiza la division entre el numero\n",
" return contador//(numero)\n",
"\n",
"#Llamamos a la funcion de impresion por consola (print) para que muestre el resultado de llamar a la funcion \"promedio\" con el arreglo \"valores\" como argumento\n",
"print(ejercicio2(lista, numero))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4.3 Encuentra el factorial de un numero usando recursion.\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Proporcione el numero del cual desea Clacular el factorial:\n",
"10\n",
"El Factorial es :\n",
"3628800\n"
]
}
],
"source": [
"# Solcicitamos el numero del cual queremos sacar el factorial \n",
"\n",
"print (\"Proporcione el numero del cual desea Clacular el factorial:\")\n",
"numero = int (input())\n",
"\n",
"#Funcion que saca el factorial del numero dado\n",
"def factorial(numero):\n",
" con = 1\n",
" for i in range(1, numero + 1):\n",
" con *= i\n",
" return con\n",
"# se imprime el resultado de la funcion \n",
"print (\"El Factorial es :\")\n",
"\n",
"print(factorial(numero))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.4 Encuentra todos los numeros que sean impares y palindromos en un rango dado."
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Proporcione el numero de Inicio de Rango::\n",
"1\n",
"Proporcione el numero de fin de Rango::\n",
"7\n",
"Los Numeros Palindromos e impares en el Rango son:\n",
"[1, 3, 5]\n"
]
}
],
"source": [
"#se pide s la lista de numeros a promediar\n",
"\n",
"print (\"Proporcione el numero de Inicio de Rango::\")\n",
"minimo = int (input())\n",
"print (\"Proporcione el numero de fin de Rango::\")\n",
"maximo = int (input())\n",
"\n",
"def ejercicio4(minimo, maximo):\n",
" \n",
" \"\"\"ejercicio4 Encuentra todos los numeros que sean impares y palindromos en un rango dado\n",
"\n",
" Args:\n",
" minimo (int): numero inicial del rango \n",
" \n",
" Examples:\n",
" Proporcione el numero de Inicio de Rango::\n",
" 1\n",
" Proporcione el numero de fin de Rango::\n",
" 7\n",
" Los Numeros Palindromos e impares en el Rango son:\n",
" [1, 3, 5]\n",
" \n",
" Proporcione el numero de Inicio de Rango::\n",
" 9\n",
" Proporcione el numero de fin de Rango::\n",
" 15\n",
" Los Numeros Palindromos e impares en el Rango son:\n",
" [9, 11]\n",
"\n",
" \"\"\" \n",
" impar = [i for i in range(minimo, maximo) if i%2 != 0]\n",
" reversestring = [int(str(i)[::-1]) for i in impar]\n",
" return list(filter(lambda x: x == int(str(x)[::-1]), impar))\n",
"print(\"Los Numeros Palindromos e impares en el Rango son:\")\n",
"print(ejercicio4(minimo,maximo))\n",
"\n",
"\n",
"#import doctest\n",
"#doctest.run_docstring_examples(ejercicio4, globals(), verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.5 Escribe una funcion que reciba una plabra y un numero e interactue con el usuario para jugar *ahorcado*, el usuario tiene un numero maximo de intentos para adivinar la palabra:\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Ahorcado_(juego))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def ejercicio5(palabra, intentos):\n",
" pass"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.6 Escribe una funcion que reciva un texto y regrese un diccionario ordenado con el numero de occurencias de cada palabra en el texto."
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'trigal': 1, 'un': 2, 'tragaban': 2, 'tigres': 1, 'tigres,': 1, 'tres': 2, 'trigo': 1, 'tristes': 2, 'trigal,': 1, 'platos': 1, 'Tres': 1, 'en': 3}\n"
]
}
],
"source": [
" \n",
"def ejercicio6(texto):\n",
" \n",
" texto = \"Tres tristes tigres, tragaban trigo en un trigal, tres tigres tragaban en tres tristes platos en un trigal\"\n",
" dicionario = texto.split()\n",
"\n",
" d = {k:dicionario.count(k) for k in list(set(dicionario))}\n",
" return (d)\n",
" \n",
" \n",
"print(ejercicio6(texto))\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.7 Escribe una clase que convierta un numero entero a numero romano."
]
},
{
"cell_type": "code",
"execution_count": 219,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MMXIX\n"
]
}
],
"source": [
"\n",
"\n",
"\n",
"class ejercicio7():\n",
" \n",
" def __init__(self):\n",
" self.eq = [(\"M\",1000), (\"CM\", 900), (\"D\", 500), (\"CD\", 400), (\"C\", 100), (\"XC\", 90),\n",
" (\"L\", 50), (\"XL\", 40), (\"X\", 10), (\"IX\", 9), (\"V\", 5), (\"IV\", 4), (\"I\", 1)]\n",
" self.dic = {\"M\":1000, \"D\":500, \"C\":100, \"L\":50, \"X\":10, \"V\":5, \"I\": 1}\n",
" \n",
" def convertir(self, n):\n",
" ans = \"\"\n",
" for r,d in self.eq:\n",
" for i in range(0,3):\n",
" if n >= d:\n",
" ans += r\n",
" n -= d\n",
" else: break\n",
" return ans\n",
"\n",
"Romanos = ejercicio7()\n",
"print(Romanos.convertir(2019))\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.8 Escribe una funcion que regrese el cuadrado mágico del tamaño indicado.\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Cuadrado_m%C3%A1gico) Cuadrado Mágico"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def ejercicio8(n):\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4 Examen Unidad 1\n",
"Escribe una función o classe y su docstring para los siguientes ejercicios. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.1 Obten el promedio de los numeros en una lista."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trying:\n",
" a = [2,7,43,87,3,65]\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" promedio(a)\n",
"Expecting:\n",
" 34.5\n",
"ok\n",
"1 items had no tests:\n",
" __main__\n",
"1 items passed all tests:\n",
" 2 tests in __main__.promedio\n",
"2 tests in 2 items.\n",
"2 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=2)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = [2,7,43,87,3,65]\n",
"def promedio(lista):\n",
" '''La función obtiene el promedio de los numeros en una lista.\n",
" \n",
" Args:\n",
" lista(list): Lista que contenga los valores a evaluar\n",
" \n",
" Ejemplo:\n",
" >>> a = [2,7,43,87,3,65]\n",
" >>> promedio(a)\n",
" 34.5\n",
" '''\n",
" return sum(lista) / len(lista)\n",
"promedio(a)\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.2 Regresa todos los numeros enteros en una lista dividida por un numero."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trying:\n",
" b = [10, 20, 30, 40, 50]\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" num = 4\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" divide(b,num)\n",
"Expecting:\n",
" [5.0, 10.0]\n",
"ok\n",
"1 items had no tests:\n",
" __main__\n",
"1 items passed all tests:\n",
" 3 tests in __main__.divide\n",
"3 tests in 2 items.\n",
"3 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=3)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = [10, 20, 30, 40, 50]\n",
"num = 4\n",
"def divide(lista, numero):\n",
" '''La función Regresa todos los numeros enteros en una lista dividida por un numero\n",
" \n",
" Args:\n",
" lista(list): Lista que contenga los valores a evaluar\n",
" numero(int): Numero que será dividido entre cada elemento de la lista\n",
" \n",
" Ejemplo:\n",
" >>> b = [10, 20, 30, 40, 50]\n",
" >>> num = 4\n",
" >>> divide(b,num)\n",
" [5.0, 10.0]\n",
" '''\n",
" return list( map(lambda z: z/numero, filter(lambda x: x%numero == 0, b)) )\n",
"\n",
" \n",
"divide(b,num)\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.3 Encuentra el factorial de un numero usando recursion.\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trying:\n",
" num = 5\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" factorial(num)\n",
"Expecting:\n",
" 120\n",
"ok\n",
"1 items had no tests:\n",
" __main__\n",
"1 items passed all tests:\n",
" 2 tests in __main__.factorial\n",
"2 tests in 2 items.\n",
"2 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=2)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"num = 5\n",
"def factorial(n):\n",
" '''La función Encuentra el factorial de un numero usando recursion\n",
" \n",
" Args:\n",
" n(int): El numero al que se quiere calcular su factorial\n",
" \n",
" Ejemplo:\n",
" >>> num = 5\n",
" >>> factorial(num)\n",
" 120\n",
" '''\n",
" if n == 1:\n",
" return n\n",
" else:\n",
" return n*factorial(n-1)\n",
" \n",
"factorial(num)\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.4 Encuentra todos los numeros que sean impares y palindromos en un rango dado."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trying:\n",
" minimo = 10\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" maximo = 300\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" palindromo_impar(minimo,maximo)\n",
"Expecting:\n",
" [11, 33, 55, 77, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191]\n",
"ok\n",
"1 items had no tests:\n",
" __main__\n",
"1 items passed all tests:\n",
" 3 tests in __main__.palindromo_impar\n",
"3 tests in 2 items.\n",
"3 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=3)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"minimo = 10\n",
"maximo = 300\n",
"def palindromo_impar(minimo, maximo):\n",
" '''La función Encuentra todos los numeros que sean impares y palindromos en un rango dado.\n",
" \n",
" Args:\n",
" minimo(int): El valor inicial del rango a evaluar\n",
" maximo(int): El valor fial del rango a evaluar\n",
" \n",
" Ejemplo:\n",
" >>> minimo = 10\n",
" >>> maximo = 300\n",
" >>> palindromo_impar(minimo,maximo)\n",
" [11, 33, 55, 77, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191]\n",
" '''\n",
" lista = []\n",
" for k in range(minimo, maximo):\n",
" if list(str(k)) == list(reversed(str(k))):\n",
" if k %2 != 0:\n",
" lista.append(k)\n",
" return lista\n",
"\n",
"palindromo_impar(minimo,maximo)\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.5 Escribe una funcion que reciba una plabra y un numero e interactue con el usuario para jugar *ahorcado*, el usuario tiene un numero maximo de intentos para adivinar la palabra:\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Ahorcado_(juego))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Introduce una palabra:ahorcado\n",
"Introduce numero de intentos:4\n",
"_ _ _ _ _ _ _ _\n",
"\n",
"Dame una letra: e\n",
"\n",
"Error, te quedan 3 intentos\n",
"\n",
"_ _ _ _ _ _ _ _\n",
"\n",
"Dame una letra: a\n",
"\n",
"a _ _ _ _ a _ _\n"
]
}
],
"source": [
"def ahorcado(palabra, intentos):\n",
" '''La función recibe una palabra y un nḿero e interactua con el usuario para jugar *ahorcado*.\n",
" \n",
" Args:\n",
" palabra(str): La palabra a adivinar\n",
" intentos(int): el valor del numero maximo de intentos para adivinar la palabra\n",
" \n",
" Ejemplo:\n",
" >>> ahorcado(palabra, intentos)\n",
" Introduce una palabra:mocoso\n",
" Introduce numero de intentos:3\n",
" _ _ _ _ _ _\n",
" '''\n",
" \n",
" palabraAdivinar = palabra\n",
" intentos = int(intentos)\n",
" \n",
" listaPalabraAdiv = []\n",
" listaPalabraMost = [] \n",
" letra = ''\n",
"\n",
" listaPalabraAdiv = list(palabraAdivinar) #Lo convierto en lista\n",
"\n",
" for item in listaPalabraAdiv:\n",
" listaPalabraMost.append('_')\n",
"\n",
" while True:\n",
"\n",
" print(' '.join(listaPalabraMost)) # Imprime los guiones\n",
"\n",
" letra = input('\\nDame una letra: ')\n",
" print()\n",
"\n",
" fallo = False\n",
"\n",
" if letra not in listaPalabraAdiv: #Intento Fallido\n",
" fallo = True\n",
" intentos -= 1\n",
" print('Error, te quedan', intentos, 'intentos\\n')\n",
" else:\n",
" for key, value in enumerate(listaPalabraAdiv): #Acertó en la palabra\n",
" if value == letra:\n",
" listaPalabraMost[key] = value\n",
"\n",
" if intentos == 0:\n",
" print('Perdiste, la palabra es \"',''.join(listaPalabraAdiv),'\"')\n",
" break\n",
" elif listaPalabraAdiv == listaPalabraMost: \n",
" print('Ganaste, la palabra es \"',''.join(listaPalabraAdiv),'\"')\n",
" break\n",
" \n",
"palabra = input('Introduce una palabra:')\n",
"numero = input('Introduce numero de intentos:')\n",
"ahorcado(palabra, numero)\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## 4.6 Escribe una funcion que reciva un texto y regrese un diccionario ordenado con el numero de occurencias de cada palabra en el texto."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trying:\n",
" texto = 'zayra prueba el ejercicio, prueba un perfume y prueba el pastel'\n",
"Expecting nothing\n",
"ok\n",
"Trying:\n",
" cuenta_palabras(texto)\n",
"Expecting:\n",
" [('ejercicio,', 1), ('el', 2), ('pastel', 1), ('perfume', 1), ('prueba', 3), ('un', 1), ('y', 1), ('zayra', 1)]\n",
"ok\n",
"1 items had no tests:\n",
" __main__\n",
"1 items passed all tests:\n",
" 2 tests in __main__.cuenta_palabras\n",
"2 tests in 2 items.\n",
"2 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=2)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def cuenta_palabras(str):\n",
" '''La función recibe un texto y regrese un diccionario ordenado con el numero de occurencias de cada palabra en el texto\n",
" \n",
" Args:\n",
" str(str): La cadena de texto a evaluar\n",
" \n",
" Ejemplo:\n",
" >>> texto = 'zayra prueba el ejercicio, prueba un perfume y prueba el pastel'\n",
" >>> cuenta_palabras(texto)\n",
" [('ejercicio,', 1), ('el', 2), ('pastel', 1), ('perfume', 1), ('prueba', 3), ('un', 1), ('y', 1), ('zayra', 1)]\n",
" '''\n",
" cuenta = dict()\n",
" texto = str.split()\n",
"\n",
" for palabra in texto:\n",
" if palabra in cuenta:\n",
" cuenta[palabra] += 1\n",
" else:\n",
" cuenta[palabra] = 1\n",
" \n",
" return sorted(cuenta.items(), key=lambda x: x[0])\n",
" \n",
" #cuenta = list(cuenta).sort(key=lambda x: x[1])\n",
"\n",
"texto = 'zayra prueba el ejercicio, prueba un perfume y prueba el pastel'\n",
"\n",
"#Al llamar al diccionario da implicito un ordenamiento por \"key\", no es necesario meter la funcion para ordenar nuevamente\n",
"cuenta_palabras(texto)\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.7 Escribe una clase que convierta un numero entero a numero romano."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MMXIX\n",
"Trying:\n",
" print(entero_romano().convierte(2019))\n",
"Expecting:\n",
" MMXIX\n",
"ok\n",
"2 items had no tests:\n",
" __main__\n",
" __main__.entero_romano\n",
"1 items passed all tests:\n",
" 1 tests in __main__.entero_romano.convierte\n",
"1 tests in 3 items.\n",
"1 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=1)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"class entero_romano:\n",
" def convierte(self, numero):\n",
" '''El metodo \"convierte\" de la clase \"entero_romano\" convierte un numero entero a numero romano.\n",
" \n",
" Args:\n",
" self(str): Variable intrinseca de instancia\n",
" numero(int): Numero entero que se desea convertir a numero romano\n",
" \n",
" Ejemplo: \n",
" >>> print(entero_romano().convierte(2019))\n",
" MMXIX\n",
" '''\n",
" enteros = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]\n",
" romanos = [\"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"]\n",
" romano_convertido = ''\n",
" i = 0\n",
" while numero > 0:\n",
" #print(\"entra a while, i=\",i)\n",
" #print(\"div=\",numero // enteros[i])\n",
" for _ in range(numero // enteros[i]):\n",
" romano_convertido += romanos[i]\n",
" #print(\"rc=\",romano_convertido)\n",
" numero -= enteros[i]\n",
" #print(\"nuevo=\",numero)\n",
" i += 1\n",
" return romano_convertido\n",
"\n",
"#Cabe mencionar que para numeros mayores a 3999 el programa no sigue las reglas originales, \n",
"#ya que no encontre forma de poner un simbolo arriba al número romano\n",
"print(entero_romano().convierte(2019))\n",
"\n",
"import doctest\n",
"doctest.testmod(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.8 Escribe una funcion que regrese el cuadrado mágico del tamaño indicado.\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Cuadrado_m%C3%A1gico) Cuadrado Mágico"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def ejercicio8(n):\n",
" pass\n",
"#complidado de programar :/"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4 Examen Unidad 1\n",
"Escribe una función o classe y su docstring para los siguientes ejercicios. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.1 Obten el promedio de los numeros en una lista."
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.0\n"
]
}
],
"source": [
"'''4.1 Obten el promedio de los numeros en una lista.'''\n",
"lista1=[2,3,5,6]\n",
"def ejercicio1(lista):\n",
" contador=0\n",
" j=0\n",
" for i in lista:\n",
" j +=i\n",
" contador +=1\n",
" resultado=j/contador\n",
" print(resultado)\n",
" pass\n",
"\n",
"ejercicio1(lista1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.2 Regresa todos los numeros enteros en una lista dividida por un numero."
]
},
{
"cell_type": "code",
"execution_count": 196,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.0\n",
"2.0\n"
]
}
],
"source": [
"'''4.2 Regresa todos los numeros enteros en una lista dividida por un numero.'''\n",
"lista2=[2,4,3,6,8,10,13]\n",
"def ejercicio2(lista, numero):\n",
" for i in lista2:\n",
" if(i%numero==0):\n",
" j=i/numero\n",
" print (j)\n",
" pass\n",
"ejercicio2(lista2,3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.3 Encuentra el factorial de un numero usando recursion.\n"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"120\n"
]
}
],
"source": [
"'''4.3 Encuentra el factorial de un numero usando recursion.'''\n",
"numero=5\n",
"def ejercicio3(numero):\n",
" resultado=0\n",
" inicio=numero\n",
" for i in range(numero-1):\n",
" inicio=inicio-1\n",
" if(numero==inicio+1):\n",
" resultado=inicio*(inicio+1)\n",
" else:\n",
" resultado=resultado*(inicio)\n",
" print(resultado)\n",
" pass\n",
"ejercicio3(numero)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.4 Encuentra todos los numeros que sean impares y palindromos en un rango dado."
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"3\n",
"5\n",
"7\n",
"9\n",
"11\n",
"33\n",
"55\n",
"77\n",
"99\n"
]
}
],
"source": [
"'''4.4 Encuentra todos los numeros que sean impares y palindromos en un rango dado.'''\n",
"minimo=0\n",
"maximo=100\n",
"listoriginal=[123,'abc','def']\n",
"listoriginal2=[123,'abc','def']\n",
"listswitch=listoriginal[::-1]\n",
"if(listoriginal==listswitch):\n",
" print(\"son iguales\")\n",
"def ejercicio4(minimo, maximo):\n",
" for i in range(minimo,maximo+1):\n",
" a=[x for x in str(i)]\n",
" b=a[::-1]\n",
" if(i%2!=0 and a==b):\n",
" print(i)\n",
" pass\n",
"ejercicio4(minimo,maximo)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.5 Escribe una funcion que reciba una plabra y un numero e interactue con el usuario para jugar *ahorcado*, el usuario tiene un numero maximo de intentos para adivinar la palabra:\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Ahorcado_(juego))"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Que palabra deseas que juegue? leon\n",
"Intentos?6\n",
"Comienza el juego...\n",
"Bienvenido a ahorcado\n",
"Intento número: 1 / 6\n",
"Que letra deseas?l\n",
"aciertos= ['l']\n",
"Acertaste, sigue asi\n",
"Intento número: 2 / 6\n",
"Que letra deseas?e\n",
"aciertos= ['l', 'e']\n",
"Acertaste, sigue asi\n",
"Intento número: 3 / 6\n",
"Que letra deseas?o\n",
"aciertos= ['l', 'e', 'o']\n",
"Acertaste, sigue asi\n",
"Intento número: 4 / 6\n",
"Que letra deseas?n\n",
"aciertos= ['l', 'e', 'o', 'n']\n",
"Acertaste, sigue asi\n",
"Intento número: 5 / 6\n",
"Que letra deseas?h\n",
"Letra incorrecta, intenta nuevamente\n",
"Intento número: 6 / 6\n",
"Que letra deseas?y\n",
"Letra incorrecta, intenta nuevamente\n",
"Lo lograste!\n",
"listpal= ['l', 'e', 'o', 'n']\n",
"listres= ['l', 'e', 'o', 'n']\n"
]
}
],
"source": [
"#supercalifragilisticoespialidoso\n",
"palabra = str(input(\"Que palabra deseas que juegue? \"))\n",
"numintentos = int(input(\"Intentos?\"))\n",
"print(\"Comienza el juego...\")\n",
"def ejercicio5(palabra, numintentos):\n",
" #print('la palabra es:',palabra,'los intentos son:',intentos)\n",
" print('Bienvenido a ahorcado')\n",
" listaciertos=[]\n",
" listpal=[x for x in str(palabra)]\n",
" listres=[]\n",
" banderaj=0\n",
" banderam=0\n",
" for i in range(numintentos):\n",
" print(\"Intento número:\",i+1,\"/\",numintentos)\n",
" intento=str(input(\"Que letra deseas?\"))\n",
" for j in listpal:\n",
" if(j==intento):\n",
" for m in listaciertos:\n",
" if(intento==m):\n",
" banderam=1\n",
" if(banderam==1):\n",
" print(\"Letra usada anteriormente (pierdes un turno), intenta otra\")\n",
" else:\n",
" listaciertos.append(intento)\n",
" print('aciertos=',listaciertos)\n",
" banderaj=1\n",
" if(banderaj==1):\n",
" print(\"Acertaste, sigue asi\")\n",
" else:\n",
" print(\"Letra incorrecta, intenta nuevamente\")\n",
" banderaj=0\n",
" banderam=0\n",
" #print(i)\n",
" if(len(listpal)==len(listaciertos)):\n",
" print(\"Lo lograste!\")\n",
" else:\n",
" print(\"No pudiste conseguirlo :/\")\n",
" print(\"listpal=\",listpal)\n",
" print(\"listres=\",listaciertos)\n",
" pass\n",
"ejercicio5(palabra,numintentos)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 4.6 Escribe una funcion que reciva un texto y regrese un diccionario ordenado con el numero de occurencias de cada palabra en el texto."
]
},
{
"cell_type": "code",
"execution_count": 175,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a : 1\n",
"el : 3\n",
"gato : 2\n",
"negro : 1\n",
"zacarias : 1\n"
]
}
],
"source": [
"texto=\"el gato gato zacarias negro el el a\"\n",
"#texto='Lorem Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'\n",
"texto2=texto.split()\n",
"def ejercicio6(texto):\n",
" val=0\n",
" usadas=[]\n",
" bandera=0\n",
" for i in texto:\n",
" #print(usadas)\n",
" bandera=0\n",
" for k in usadas:\n",
" #print(k)\n",
" if(i==k[0] and bandera==0):\n",
" bandera=1\n",
" #usadas[1]+=1\n",
" for m in usadas:\n",
" if(m[0]==k[0]):\n",
" m[1]+=1\n",
" if(bandera==0):\n",
" usadas.append([i,1])\n",
" used=sorted(usadas) \n",
" #print(used)\n",
" for i in used:\n",
" print(i[0],\":\",i[1])\n",
" \n",
" pass\n",
"\n",
"def alphaonly(text):\n",
" resultado=\"\"\n",
" uso=[x for x in str(text)]\n",
" for char in uso:\n",
" if(char.isalpha()):\n",
" resultado=resultado+char\n",
" return resultado\n",
" pass\n",
"\n",
"texto3=[]\n",
"for i in texto2:\n",
" j=alphaonly(i)\n",
" #print(j)\n",
" texto3.append(j)\n",
"#print(texto3)\n",
"ejercicio6(texto3)\n",
"#res = list(set(lista) & set(lista2)) para intersecciones de conjuntos en listados"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.7 Escribe una clase que convierta un numero entero a numero romano."
]
},
{
"cell_type": "code",
"execution_count": 219,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ingresa el número:10\n",
"10:\n",
"x"
]
},
{
"data": {
"text/plain": [
"<__main__.ejercicio7 at 0x7f509826a8d0>"
]
},
"execution_count": 219,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"class ejercicio7:\n",
" numdec=[9000,5000,4000,1000,900,500,400,100,90,50,40,10,9,5,4,1]\n",
" rom=[\"IX'\",\"V'\",\"IV'\",\"m\",\"cm\",\"d\",\"cd\",\"c\",\"cx\",\"i\",\"xi\",\"x\",\"ix\",\"v\",\"iv\",\"i\",]\n",
" def __init__(self,numinsertado):\n",
" \n",
" if(numinsertado==0):\n",
" print(\"No existe el cero en romanos\")\n",
" print (str(numinsertado)+\":\")\n",
"\n",
" i=0\n",
" while(numinsertado>0):\n",
" if(numinsertado>=numdec[i]):\n",
" print(str(rom[i]),end=\"\")\n",
" numinsertado=numinsertado-numdec[i]\n",
" else:\n",
" i=i+1\n",
" pass\n",
"\n",
"numinsertado=int(input(\"Ingresa el número:\"))\n",
"ejercicio7(numinsertado)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.8 Escribe una funcion que regrese el cuadrado mágico del tamaño indicado.\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Cuadrado_m%C3%A1gico) Cuadrado Mágico"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def ejercicio8(n):\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
......@@ -4,8 +4,1956 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2.SciPy\n",
"## 2.1 NumPy"
"![scipy](https://cdn-images-1.medium.com/max/1600/1*Y2v3PrF1rUQRUHwOcXJznA.png)\n",
"\n",
"# 5.SciPy\n",
"SciPy es un ecosistema para computo cientifico en python, esta constriuido sobre los arreglos de NumPy. Scipy incluye herramientas como Matplotlib, pandas , SymPy y scikit-learn. \n",
"\n",
"## 5.1 NumPy\n",
"NumPy es la base para todos los paquetes de computo científico en python, provee soporte para arreglos multidimensionales y matrices, junto con una amplia coleccion de funciones matematicas de alto nivel para operar con estos arreglos.\n",
"\n",
"### 5.1.1 numpy.array \n",
"El tipo de dato mas importante de numpy es **numpy.array** sus atibutos mas importantes son:\n",
"* numpy.array.**ndim**: -numero de dimensiones del arreglo.\n",
"* numpy.array.**shape**: Un tupla indicando el tamaño del arreglo en cada dimension.\n",
"* numpy.array.**size**: El numero total elementos en el arreglo.\n",
"* numpy.array.**dtype**: El tipo de elemenos en el arreglo e.g. numpy.int32, numpy.int16, and numpy.float64.\n",
"* numpy.array.**itemsize**: el tamaño en bytes de cada elemento del arrglo.\n",
"* numpy.array.**data**: El bloque de memoria que contiene los datos del arreglo.\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0 1 2 3 4]\n",
" [ 5 6 7 8 9]\n",
" [10 11 12 13 14]]\n",
"(3, 5)\n",
"2\n",
"int64\n"
]
}
],
"source": [
"import numpy as np\n",
"a = np.array([[ 0, 1, 2, 3, 4],\n",
" [ 5, 6, 7, 8, 9],\n",
" [10, 11, 12, 13, 14]])\n",
"print(a)\n",
"print(a.shape)\n",
"print(a.ndim)\n",
"print(a.dtype)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1.+0.j, 2.+0.j],\n",
" [3.+0.j, 4.+0.j]])"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c = np.array( [ [1,2], [3,4] ], dtype=complex )\n",
"c"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0., 0., 0., 0.],\n",
" [0., 0., 0., 0.],\n",
" [0., 0., 0., 0.]])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
" np.zeros( (3,4) )\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1., 1., 1., 1.],\n",
" [1., 1., 1., 1.],\n",
" [1., 1., 1., 1.]])"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.ones( (3,4)) "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1., 1., 1., 1.],\n",
" [1., 1., 1., 1.],\n",
" [1., 1., 1., 1.]])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.empty( (3,4) ) "
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1., 0., 0., 0., 0.],\n",
" [0., 1., 0., 0., 0.],\n",
" [0., 0., 1., 0., 0.],\n",
" [0., 0., 0., 1., 0.],\n",
" [0., 0., 0., 0., 1.]])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.eye(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Operaciones Basicas"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"a = np.array([20,30,40,50] )\n",
"b = np.arange( 4 )"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([20, 29, 38, 47])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Suma\n",
"a-b"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 40, 60, 80, 100])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Multiplicacion por Escalar\n",
"a*2"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 4, 9])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Potencia\n",
"b**2"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ True, True, True, False])"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Operadores Boleanos\n",
"a<50"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 30, 80, 150])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Multiplicacion por elemento\n",
"a*b"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"66"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c= np.arange(12).reshape(3,4)\n",
"c.sum()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([12, 15, 18, 21])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c.sum(axis=0) # Suma por Columna"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 6, 22, 38])"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c.sum(axis=1) #Suma por Fila"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[**Producto punto**](https://en.wikipedia.org/wiki/Dot_product) y [**Multiplicacion Matricial**](https://en.wikipedia.org/wiki/Matrix_multiplication)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a@b == a.dot(b)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"A = np.array([[1, 0], [0, 1]])\n",
"B = np.array([[4, 1], [2, 2]]) "
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ True, True],\n",
" [ True, True]])"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.matmul(A, B) == A.dot(B)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Elementos, filas, columnas y submatrices."
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 0, 1, 2, 3],\n",
" [10, 11, 12, 13],\n",
" [20, 21, 22, 23],\n",
" [30, 31, 32, 33],\n",
" [40, 41, 42, 43]])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def f(x,y):\n",
" return 10*x+y\n",
"B = np.fromfunction(f,(5,4),dtype=int)\n",
"B"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"B[0,3]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([10, 11, 12, 13])"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"B[1,:]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 1, 11, 21, 31, 41])"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"B[:,1]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1, 2],\n",
" [11, 12]])"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"B[:2,1:3]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Iterando elementos"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0 1 2 3]\n",
"[10 11 12 13]\n",
"[20 21 22 23]\n",
"[30 31 32 33]\n",
"[40 41 42 43]\n"
]
}
],
"source": [
"for row in B:\n",
" print(row)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"2\n",
"3\n",
"10\n",
"11\n",
"12\n",
"13\n",
"20\n",
"21\n",
"22\n",
"23\n",
"30\n",
"31\n",
"32\n",
"33\n",
"40\n",
"41\n",
"42\n",
"43\n"
]
}
],
"source": [
"for element in B.flat:\n",
" print(element)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cambio de forma"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[2., 9., 8., 6.],\n",
" [8., 4., 2., 9.],\n",
" [1., 1., 4., 5.]])"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = np.floor(10*np.random.random((3,4)))\n",
"a"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(3, 4)"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.shape"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[2., 9.],\n",
" [8., 6.],\n",
" [8., 4.],\n",
" [2., 9.],\n",
" [1., 1.],\n",
" [4., 5.]])"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.reshape(6,2)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[2., 8., 1.],\n",
" [9., 4., 1.],\n",
" [8., 2., 4.],\n",
" [6., 9., 5.]])"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.T"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ True, True, True],\n",
" [ True, True, True],\n",
" [ True, True, True],\n",
" [ True, True, True]])"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.transpose()==a.T"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(4, 3)"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.T.shape"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[2., 9., 8., 6.],\n",
" [8., 4., 2., 9.],\n",
" [1., 1., 4., 5.]])"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# La dimensión con -1 se calcula automaticamente\n",
"a.reshape(3,-1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5.2 Ejercicos\n",
"\n",
"### 5.2.1 Sin utilizar numpy escribe una funcion para obten el producto punto de dos vectores."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"a = [2, 5.6, 9, 8, 10]\n",
"b = [1, 3, 2.4, 2, 11]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.2 Sin utilizar numpy escribe una funcion que obtenga la multiplicacion de dos matrices.\n"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"A = [[1,2,3],[4,5,6]]\n",
"B = [[7,8],[9,10],[11,12]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.3 Utiliza numpy para probar que las dos funciones anteriores dan el resultado correcto."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.4 Utilizando solo lo visto hasta el momento de numpy escribe una funcion que encuentre la inversa de una matriz por el metodo de Gauss-Jordan.\n",
"[Wikipedia](https://en.wikipedia.org/wiki/Gaussian_elimination): En matemáticas, la eliminación de Gauss Jordan, llamada así en honor de Carl Friedrich Gauss y Wilhelm Jordan es un algoritmo del álgebra lineal que se usa para determinar las soluciones de un sistema de ecuaciones lineales, para encontrar matrices e inversas. Un sistema de ecuaciones se resuelve por el método de Gauss cuando se obtienen sus soluciones mediante la reducción del sistema dado a otro equivalente en el que cada ecuación tiene una incógnita menos que la anterior. El método de Gauss transforma la matriz de coeficientes en una matriz triangular superior. El método de Gauss-Jordan continúa el proceso de transformación hasta obtener una matriz diagonal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.5 Utilizando la funcion anterior escribe otra que obtenga la pseduo-inversa de una matriz."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5.3 Pandas\n",
"En python, pandas es una biblioteca de software escrita como extensión de NumPy para manipulación y análisis de datos. En particular, ofrece estructuras de datos y operaciones para manipular tablas numéricas y series temporales.\n",
"and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. Su objetivo es ser un bloque de construccion fundamental para realizar analisis de datos en el mundo real.\n",
"El nombre de la biblioteca deriva del término \"datos de panel\" (PANel DAta), término de econometría que designa datos que combinan una dimensión temporal con otra dimensión transversal.\n",
"\n",
"Pandas tiene dos typos de datos principales, **Series** (1D) y **DataFrame** (2D), *Dataframe* es un contenedr para *Series* y *Series* es un contenedor de escalares. \n",
"\n",
"### 5.3.1 Series\n",
"Series es un arreglo unidimensional etiquetado capaz de contener cualquier tipo de dato (Enteros, cadenas, punto flotante, objetos, etc), El eje de etiquetas es llamado indice (**index**).\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a 1.085164\n",
"b 0.684054\n",
"c -3.137046\n",
"d -0.780916\n",
"e 0.497413\n",
"dtype: float64"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])\n",
"s"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 -0.165303\n",
"1 0.089697\n",
"2 -1.680879\n",
"3 -0.160729\n",
"4 0.235082\n",
"dtype: float64"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.Series(np.random.randn(5))"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a 0\n",
"b 1\n",
"c 2\n",
"dtype: int64"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d = {'b': 1, 'a': 0, 'c': 2}\n",
"pd.Series(d)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b 1.0\n",
"c 2.0\n",
"d NaN\n",
"a 0.0\n",
"dtype: float64"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d = {'a': 0., 'b': 1., 'c': 2.}\n",
"pd.Series(d, index=['b', 'c', 'd', 'a'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Las Series son compatibles con *numpy.array* y *dict*"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0851635954341003"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s[0]"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a 1.085164\n",
"b 0.684054\n",
"c -3.137046\n",
"dtype: float64"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s[:3]"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a 1.085164\n",
"b 0.684054\n",
"e 0.497413\n",
"dtype: float64"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s[s>s.mean()]"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a 2.170327\n",
"b 1.368108\n",
"c -6.274092\n",
"d -1.561832\n",
"e 0.994826\n",
"dtype: float64"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s*2"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a True\n",
"b True\n",
"c False\n",
"d False\n",
"e False\n",
"dtype: bool"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s>s.median()"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0851635954341003"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s[\"a\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Alieneacion Automatica"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [],
"source": [
"a = np.array(range(10))\n",
"s = pd.Series(a)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 0\n",
"1 1\n",
"2 2\n",
"3 3\n",
"4 4\n",
"5 5\n",
"6 6\n",
"7 7\n",
"8 8\n",
"9 9\n",
"dtype: int64"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 4, 6, 8, 10, 12, 14])"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(a[:6]+a[4:])"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 NaN\n",
"1 NaN\n",
"2 NaN\n",
"3 NaN\n",
"4 8.0\n",
"5 10.0\n",
"6 NaN\n",
"7 NaN\n",
"8 NaN\n",
"9 NaN\n",
"dtype: float64"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(s[:6]+s[4:])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.3.2 DataFrame\n",
"DataFrame es un estructura bidimensional etiquetada con columnas que pueden ser de diferentes tipos, es el objeto mas usado en pandas, se puede pensar en ella como un diccionario de **Series**. **DataFrame** acepta diferentes tipos de entradas como:\n",
"* Diccionarios de arreglos unidimensionales, listas dicionarios o series. \n",
"* 2-D numpy.ndarray\n",
"* Series\n",
"* Otro **DataFrame**"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
"d = {'one': pd.Series([1., 2., 3.], index=['a', 'b', 'c']),\n",
" 'two': pd.Series([1., 2., 3., 4.], index=['a', 'x', 'c', 'd'])}"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(d)"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>one</th>\n",
" <th>two</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>a</th>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>b</th>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>c</th>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>d</th>\n",
" <td>NaN</td>\n",
" <td>4.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" one two\n",
"a 1.0 1.0\n",
"b 2.0 NaN\n",
"c 3.0 3.0\n",
"d NaN 4.0\n",
"x NaN 2.0"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Seleccionar, Añadir y Borrar Columnas"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"a 1.0\n",
"b 2.0\n",
"c 3.0\n",
"d NaN\n",
"x NaN\n",
"Name: one, dtype: float64"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[\"one\"]"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>one</th>\n",
" <th>two</th>\n",
" <th>three</th>\n",
" <th>flag</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>a</th>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>b</th>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>c</th>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
" <td>9.0</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>d</th>\n",
" <td>NaN</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" one two three flag\n",
"a 1.0 1.0 1.0 False\n",
"b 2.0 NaN NaN False\n",
"c 3.0 3.0 9.0 True\n",
"d NaN 4.0 NaN False\n",
"x NaN 2.0 NaN False"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['three'] = df['one'] * df['two']\n",
"df['flag'] = df['one'] > 2\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [],
"source": [
"del df['two']"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [],
"source": [
"three = df.pop('three')"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>one</th>\n",
" <th>flag</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>a</th>\n",
" <td>1.0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>b</th>\n",
" <td>2.0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>c</th>\n",
" <td>3.0</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>d</th>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" one flag\n",
"a 1.0 False\n",
"b 2.0 False\n",
"c 3.0 True\n",
"d NaN False\n",
"x NaN False"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>one</th>\n",
" <th>two</th>\n",
" <th>flag</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>a</th>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>b</th>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>c</th>\n",
" <td>3.0</td>\n",
" <td>9.0</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>d</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" one two flag\n",
"a 1.0 1.0 False\n",
"b 2.0 NaN False\n",
"c 3.0 9.0 True\n",
"d NaN NaN False\n",
"x NaN NaN False"
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# inserta la columna three en la posición 1 bajo el nombre two\n",
"df.insert(1, \"two\", three)\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Indexado y Selección\n",
"\n",
"| Operación | Sintaxis | Resultado |\n",
"|:----------|:--------:|:----------|\n",
"| Selección de Columna | df[col] | Series |\n",
"| Selección de fila por etiqueta | df.loc[label] | Series |\n",
"| Selección de fila por posición | df.iloc[loc] | Series |\n",
"| Rango de filas | df[5:10] | DataFrame |\n",
"| Selección de filas por vector booleano | df[bool_vec] | DataFrame |\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"one 1\n",
"two 1\n",
"flag False\n",
"Name: a, dtype: object"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc['a']"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"one 3\n",
"two 9\n",
"flag True\n",
"Name: c, dtype: object"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.iloc[2]"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>one</th>\n",
" <th>two</th>\n",
" <th>flag</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>a</th>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>b</th>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" one two flag\n",
"a 1.0 1.0 False\n",
"b 2.0 NaN False"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[:2]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5.4 Ejercicios\n",
"Los siguentes ejercicios de realizann con los dato de *iris.csv*"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sepal_length</th>\n",
" <th>sepal_width</th>\n",
" <th>petal_length</th>\n",
" <th>petal_width</th>\n",
" <th>species</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sepal_length sepal_width petal_length petal_width species\n",
"0 5.1 3.5 1.4 0.2 setosa\n",
"1 4.9 3.0 1.4 0.2 setosa\n",
"2 4.7 3.2 1.3 0.2 setosa\n",
"3 4.6 3.1 1.5 0.2 setosa\n",
"4 5.0 3.6 1.4 0.2 setosa"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"iris = pd.read_csv('data/iris.csv')\n",
"iris.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.1 ¿Cual es el numero de observaciones en el conjunto de datos?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.2 ¿Cual es el numero de columnas en el conjunto de datos?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.3 Imprime el nombre de todas las columnas"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.4 ¿Cual es el nombre de la columna 4?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.5 Selecciona las columnas, \"sepal_length\" y \"petal_length\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.6 Selecciona las filas en donde \"sepal_length\" sea mayor a 4.8"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.7 Agrega una nueva columna que sea la muliplicacion de \"petal_length\" por \"petal_width\""
]
},
{
......@@ -19,7 +1967,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2.2 Pandas"
"### 5.4.8 Encuentra el promedio por especie de cada columna."
]
},
{
......@@ -46,7 +1994,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8rc1"
"version": "3.5.3"
}
},
"nbformat": 4,
......
......@@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8rc1"
"version": "3.5.3"
}
},
"nbformat": 4,
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3. Herramientas\n",
"## 3.5 Scrapy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3.6 Scrapy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 4 Examen Unidad 1\n",
"Escribe una función o classe y su docstring para los siguientes ejercicios. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.1 Obten el promedio de los numeros en una lista."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Lista [8, 10, 10, 10]\n",
"Cantidad de posiciones de lista 4\n",
"promedio de la lista 9.5\n"
]
}
],
"source": [
"valores=[8,10,10,10]\n",
"def promedio(valores):\n",
" print (\"Lista\",valores)\n",
" sumaParcial = 0.0\n",
" for valor in valores:\n",
" sumaParcial+=valor\n",
" CantidadValores=len(valores)\n",
" print (\"Cantidad de posiciones de lista\",CantidadValores)\n",
" return sumaParcial/float(CantidadValores)\n",
"print (\"promedio de la lista\",promedio(valores))\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.2 Regresa todos los numeros enteros en una lista dividida por un numero."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 130,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 3, 6, 9]"
]
},
"execution_count": 130,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
"\n",
"new_list=[i for i in a if i%3==0]\n",
"new_list"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.3 Encuentra el factorial de un numero usando recursion.\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"numero aplicar factiorial5\n",
"el factorial de 5 es 120\n"
]
}
],
"source": [
"def factorial(numero):\n",
" if(numero== 0 or numero ==1):\n",
" return 1\n",
" else:\n",
" return numero * factorial(numero-1)\n",
"if __name__==\"__main__\":\n",
" try:\n",
" num = int(input(\"numero aplicar factiorial\"))\n",
" if (num < 0):\n",
" print (\"El numero debe ser mayor o igual a 0\")\n",
" else:\n",
" print (\"el factorial de \", num, \"es\" ,factorial(num))\n",
" except:\n",
" print (\"se espera un numero\")\n",
" pass"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.4 Encuentra todos los numeros que sean impares y palindromos en un rango dado."
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1, 3, 5, 7, 9, 11, 33, 55, 77, 99, 101, 111]"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def isPalindrome(s):\n",
" s = str(s)\n",
" return s == s[:: -1]\n",
"def generate_palindrome(minimo, maximo):\n",
" tmpList=[]\n",
" for i in range(minimo, maximo+1):\n",
" if isPalindrome(i):\n",
" if i%2!=0:\n",
" tmpList.append(i)\n",
" return tmpList\n",
"\n",
"generate_palindrome (1,120)\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.6 Escribe una funcion que reciva un texto y regrese un diccionario ordenado con el numero de occurencias de cada palabra en el texto."
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 -> Sandia\n",
"3 -> Melon\n",
"5 -> ciruela\n",
"6 -> sandia\n",
"7 -> naranja\n",
"8 -> fresa\n",
"11 -> Papaya\n",
"14 -> coco\n",
"15 -> guanaba\n",
"16 -> limon\n",
"18 -> chile\n",
"\n",
"Numero de elementos del diccionario len(Frutas) = 11\n",
"\n",
"Valores del diccionario Frutas.values(): \n",
"dict_values(['limon', 'Sandia', 'chile', 'Melon', 'ciruela', 'sandia', 'naranja', 'fresa', 'Papaya', 'coco', 'guanaba'])\n"
]
}
],
"source": [
"Frutas = dict()\n",
"\n",
"Frutas = {\n",
" 1 : \"Sandia\", 15 : \"guanaba\",\n",
" 3 : \"Melon\", 5 : \"ciruela\",\n",
" 11 : \"Papaya\", 14 : \"coco\",\n",
" 16 : \"limon\", 8 : \"fresa\",\n",
" 18 : \"chile\", 6 : \"sandia\",\n",
" 7 : \"naranja\"\n",
"}\n",
"\n",
"# Recorrer un diccionario, imprimiendo su clave-valor\n",
"for k,v in sorted(Frutas.items()):\n",
" print (\"%s -> %s\" %(k,v))\n",
"\n",
"# Vemos cuantos elementos tiene nuestro diccionario\n",
"numElem = len(Frutas)\n",
"print (\"\\nNumero de elementos del diccionario len(Frutas) = %i\" %numElem)\n",
"\n",
"\n",
"# Imprimimos en una lista los valores del diccionario\n",
"values = Frutas.values()\n",
"print (\"\\nValores del diccionario Frutas.values(): \\n%s\" %values)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4.7 Escribe una clase que convierta un numero entero a numero romano."
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Favor de ingresar un numero decimal / o terminar :10\n",
"10:\n",
"x\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m~/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 877\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 878\u001b[0;31m \u001b[0mident\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreply\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msession\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstdin_socket\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 879\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.5/site-packages/jupyter_client/session.py\u001b[0m in \u001b[0;36mrecv\u001b[0;34m(self, socket, mode, content, copy)\u001b[0m\n\u001b[1;32m 802\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 803\u001b[0;31m \u001b[0mmsg_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msocket\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv_multipart\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 804\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mzmq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mZMQError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.5/site-packages/zmq/sugar/socket.py\u001b[0m in \u001b[0;36mrecv_multipart\u001b[0;34m(self, flags, copy, track)\u001b[0m\n\u001b[1;32m 466\u001b[0m \"\"\"\n\u001b[0;32m--> 467\u001b[0;31m \u001b[0mparts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mflags\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrack\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtrack\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 468\u001b[0m \u001b[0;31m# have first part already, only loop while more to receive\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket.Socket.recv\u001b[0;34m()\u001b[0m\n",
"\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket.Socket.recv\u001b[0;34m()\u001b[0m\n",
"\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket._recv_copy\u001b[0;34m()\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.5/site-packages/zmq/backend/cython/checkrc.pxd\u001b[0m in \u001b[0;36mzmq.backend.cython.checkrc._check_rc\u001b[0;34m()\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: ",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-127-4f88054cdbcf>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mwhile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"\\n Favor de ingresar un numero decimal / o terminar :\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 851\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 852\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 853\u001b[0;31m \u001b[0mpassword\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 854\u001b[0m )\n\u001b[1;32m 855\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 881\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 882\u001b[0m \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 883\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 884\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 885\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"Vn= [1000,900,500,400,100,90,50,40,10,9,5,4,1]\n",
"Vc=[\"m\",\"cm\",\"d\",\"cd\",\"c\",\"cx\",\"l\",\"xl\",\"x\",\"ix\",\"v\",\"iv\",\"i\"]\n",
"\n",
"while(True):\n",
" x = int(input(\"\\n Favor de ingresar un numero decimal / o terminar :\"))\n",
" \n",
" if (x==0):\n",
" break\n",
" print (str(x) + \":\")\n",
" \n",
" i=0\n",
" while( x>0):\n",
" if (x >= Vn[i]):\n",
" print (str(Vc[i]))\n",
" x = x- Vn[i]\n",
" else:\n",
" i=i+1\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment