├── .gitignore ├── Examples ├── Digit Recognition .ipynb ├── Examen Final - FC.ipynb ├── Numeros Aleatorios.ipynb ├── Oscilador Duffing.ipynb └── Sistemas Discretos y Caos.ipynb ├── LICENSE ├── Notebooks ├── 00-Instalación e Introducción.ipynb ├── 01-Python - Sintaxis.ipynb ├── 02-Contro de Flujo y Bucles.ipynb ├── 03-Colecciones en Python.ipynb ├── 04-Funciones.ipynb ├── 05-Programacion orientada a objetos.ipynb ├── 06-Archivos, Manejo de Errores & Excepciones.ipynb ├── 07-Expresiones Regulares.ipynb ├── 08-Numpy - Introducción.ipynb ├── 09-Matplotlib.ipynb ├── 10-Sympy.ipynb ├── 11-Pandas.ipynb ├── 12-Scipy.ipynb ├── 13-Scikit-Learn.ipynb ├── filename.png ├── foo.txt ├── foo1.txt ├── miarchivo.txt ├── numeros.txt ├── numeros2.txt └── script1.py ├── README.md ├── data ├── 50_Startups.csv ├── Data.csv ├── Mall_Customers.csv ├── Position_Salaries.csv ├── Salary_Data.csv ├── Social_Network_Ads.csv ├── children_heights.txt ├── crime.csv ├── imdb.csv ├── mortality.csv ├── titanic.csv └── ufo.csv ├── images ├── Lenna.png ├── array.gif ├── array.png ├── cars.jpg ├── clasification.png ├── clasification2.png ├── clasiregre.png ├── cluster.png ├── dataframe.jpg ├── diagram.png ├── elif.png ├── elseIfDiagram.png ├── flujo1.png ├── flujo2.png ├── flujo3.png ├── flujo4.png ├── flujo5.png ├── function.png ├── instalation1.png ├── instalation2.png ├── instalation3.png ├── instalation4.png ├── instalation5.png ├── instalation6.png ├── instalation7.png ├── lenna2.png ├── listas.png ├── logot.jpg ├── machine_learning.jpg ├── markdown0.gif ├── markdown1.gif ├── markdown2.gif ├── markdown3.gif ├── matrizslice.png ├── ml_applications.png ├── ml_map.png ├── numpy_broadcasting.png ├── passtest.gif ├── pi.png ├── process_SL.png ├── procons.png ├── python_dict.png ├── reduce.png ├── reduce_diagram.png ├── serie.png ├── series.jpg ├── series2.jpg ├── series3.jpg ├── test1.gif ├── test2.gif ├── test3.gif ├── test4.gif ├── tokens.png ├── unsuper.jpg ├── validos.png └── why.png └── styles ├── FluxBold.ttf └── StyleCursoPython.css /.gitignore: -------------------------------------------------------------------------------- 1 | ### JupyterNotebook ### 2 | .ipynb_checkpoints 3 | */.ipynb_checkpoints/* 4 | -------------------------------------------------------------------------------- /Examples/Digit Recognition .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Reconocimiento de digitos usando KNN" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "Importamos las librerías necesarias" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": { 21 | "collapsed": false 22 | }, 23 | "outputs": [], 24 | "source": [ 25 | "import numpy as np\n", 26 | "import sklearn\n", 27 | "import sklearn.datasets as ds\n", 28 | "import sklearn.model_selection as cv\n", 29 | "import sklearn.neighbors as nb\n", 30 | "import matplotlib.pyplot as plt\n", 31 | "%matplotlib inline\n", 32 | "plt.rcParams['figure.figsize'] = (12, 10)" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "cargamos los digitos " 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 2, 45 | "metadata": { 46 | "collapsed": false 47 | }, 48 | "outputs": [ 49 | { 50 | "name": "stdout", 51 | "output_type": "stream", 52 | "text": [ 53 | "(0.0, 16.0)\n", 54 | "(1797, 64)\n" 55 | ] 56 | } 57 | ], 58 | "source": [ 59 | "digits = ds.load_digits()\n", 60 | "X = digits.data\n", 61 | "y = digits.target\n", 62 | "print((X.min(), X.max()))\n", 63 | "print(X.shape)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "## Más infomacion acerca de esta data en \n", 71 | "http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 3, 77 | "metadata": { 78 | "collapsed": false 79 | }, 80 | "outputs": [ 81 | { 82 | "data": { 83 | "image/png": "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\n", 84 | "text/plain": [ 85 | "" 86 | ] 87 | }, 88 | "metadata": {}, 89 | "output_type": "display_data" 90 | } 91 | ], 92 | "source": [ 93 | "nrows, ncols = 2, 5\n", 94 | "plt.figure(figsize=(6,3));\n", 95 | "plt.gray()\n", 96 | "for i in range(ncols * nrows):\n", 97 | " ax = plt.subplot(nrows, ncols, i + 1)\n", 98 | " ax.matshow(digits.images[i,...])\n", 99 | " plt.xticks([]); plt.yticks([]);\n", 100 | " plt.title(digits.target[i]);" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "Separamos nuestra data de entrenamiento y nuestra data de prueba:" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 4, 113 | "metadata": { 114 | "collapsed": true 115 | }, 116 | "outputs": [], 117 | "source": [ 118 | "(X_train, X_test, \n", 119 | " y_train, y_test) = cv.train_test_split(X, y, test_size=.25)" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "Usamos el clasificador de KNN" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 5, 132 | "metadata": { 133 | "collapsed": true 134 | }, 135 | "outputs": [], 136 | "source": [ 137 | "knc = nb.KNeighborsClassifier()" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 6, 143 | "metadata": { 144 | "collapsed": true 145 | }, 146 | "outputs": [], 147 | "source": [ 148 | "knc.fit(X_train, y_train);" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "Nos da un margen de acierto de un 98.2%" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": 7, 161 | "metadata": { 162 | "collapsed": false 163 | }, 164 | "outputs": [ 165 | { 166 | "data": { 167 | "text/plain": [ 168 | "0.98666666666666669" 169 | ] 170 | }, 171 | "execution_count": 7, 172 | "metadata": {}, 173 | "output_type": "execute_result" 174 | } 175 | ], 176 | "source": [ 177 | "knc.score(X_test, y_test)" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 8, 183 | "metadata": { 184 | "collapsed": false 185 | }, 186 | "outputs": [ 187 | { 188 | "data": { 189 | "text/plain": [ 190 | "array([[ 0., 0., 0., 0., 0., 0., 0., 0.],\n", 191 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 192 | " [ 0., 0., 0., 16., 16., 0., 0., 0.],\n", 193 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 194 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 195 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 196 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 197 | " [ 0., 0., 0., 0., 0., 0., 0., 0.]])" 198 | ] 199 | }, 200 | "execution_count": 8, 201 | "metadata": {}, 202 | "output_type": "execute_result" 203 | } 204 | ], 205 | "source": [ 206 | "# Dibujamos un 1 \n", 207 | "one = np.zeros((8, 8))\n", 208 | "one[1:-1, 4] = 16 # The image values are in [0, 16].\n", 209 | "one[2, 3] = 16\n", 210 | "one" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 9, 216 | "metadata": { 217 | "collapsed": false 218 | }, 219 | "outputs": [ 220 | { 221 | "data": { 222 | "image/png": "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\n", 223 | "text/plain": [ 224 | "" 225 | ] 226 | }, 227 | "metadata": {}, 228 | "output_type": "display_data" 229 | } 230 | ], 231 | "source": [ 232 | "plt.figure(figsize=(2,2));\n", 233 | "plt.imshow(one, interpolation='none');\n", 234 | "plt.grid(False);\n", 235 | "plt.xticks(); plt.yticks();\n", 236 | "plt.title(\"One\");" 237 | ] 238 | }, 239 | { 240 | "cell_type": "code", 241 | "execution_count": 10, 242 | "metadata": { 243 | "collapsed": false, 244 | "scrolled": false 245 | }, 246 | "outputs": [ 247 | { 248 | "name": "stderr", 249 | "output_type": "stream", 250 | "text": [ 251 | "/home/gerson/anaconda3/envs/py3/lib/python3.6/site-packages/sklearn/utils/validation.py:395: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.\n", 252 | " DeprecationWarning)\n" 253 | ] 254 | }, 255 | { 256 | "data": { 257 | "text/plain": [ 258 | "array([1])" 259 | ] 260 | }, 261 | "execution_count": 10, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "knc.predict(one.ravel())" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 11, 273 | "metadata": { 274 | "collapsed": false 275 | }, 276 | "outputs": [ 277 | { 278 | "data": { 279 | "text/plain": [ 280 | "array([[ 0., 0., 0., 0., 0., 0., 0., 0.],\n", 281 | " [ 0., 0., 16., 16., 16., 0., 0., 0.],\n", 282 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 283 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 284 | " [ 0., 0., 0., 16., 16., 16., 0., 0.],\n", 285 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 286 | " [ 0., 0., 0., 0., 16., 0., 0., 0.],\n", 287 | " [ 0., 0., 0., 0., 0., 0., 0., 0.]])" 288 | ] 289 | }, 290 | "execution_count": 11, 291 | "metadata": {}, 292 | "output_type": "execute_result" 293 | } 294 | ], 295 | "source": [ 296 | "# Dibujamos un 7 \n", 297 | "seven = np.zeros((8, 8))\n", 298 | "seven[1:-1, 4] = 16 # The image values are in [0, 16].\n", 299 | "seven[1, 2:5] = 16\n", 300 | "seven[4, 3:6] = 16\n", 301 | "seven" 302 | ] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": 12, 307 | "metadata": { 308 | "collapsed": false 309 | }, 310 | "outputs": [ 311 | { 312 | "data": { 313 | "text/plain": [ 314 | "" 315 | ] 316 | }, 317 | "execution_count": 12, 318 | "metadata": {}, 319 | "output_type": "execute_result" 320 | }, 321 | { 322 | "data": { 323 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIsAAACcCAYAAABPyljcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAB2dJREFUeJzt3W2IHeUZxvH/5dqgtUkURDHZECNYtc0HlVSRplKo1pcG\n4gcLRhRsixFBVFRaFS1+k0Ip5lNLCGoL1SDaUBF1rVhoMSQmUanmRVkSNRsUX2JMqGkl9vbDzOLZ\nYPfcbs6ZM3Pm+sGy58zLzrNnr71nzszzzFFEYJZx1KAbYM3hsFiaw2JpDoulOSyW5rBYmsNiaa0J\ni6SlktZL+kTSXkkvSvreoNvVJEcPugFVkDQHeAq4EXgMmAX8APjvINvVNG2pLN8GiIhHI+LziDgY\nEc9FxL8AJP1c0nZJH0sak7SwnP57Sb/t/EGS/irptvLxPElPSPpA0i5JN3csd5+kxyT9SdIBSVsl\nLanuV+6DiBj6L2AO8BHwR+Ay4ISOecuBceAsikp7D7C+nHchsBtQ+fwE4CAwj+IfbQvwa4pKdRqw\nE7ikXPY+4D/A5cAIcD+wYdCvxRG9joNuQIWBOQt4GJgADgFPAicDzwC/6FjuKOBTYCEg4B3gwnLe\n9cAL5ePzgXcO28ZdwEMdYXm+Y953gIODfh2O5KstuyEiYntEXBcRo8BiiurwAEUoVknaJ2kfsJci\nJPOj+CuvBVaUP+Zq4M/l44XAvMn1ynXvpgjgpPc6Hn8KHCOpsceJrQlLp4jYQVFlFlPsZm6IiOM7\nvo6NiPXl4o8CV5bHMecDT5TTdwO7DltvdkRcXvGvU5lWhEXSmZJulzRaPl9AUS02AH8A7pL03XLe\nXEk/nVw3Il4BPgTWAGMRsa+c9RJwQNKvJB0raUTS4mF+O96KsAAHKKrCRkn/pgjJ68DtEbEO+A2w\nVtL+cvplh63/CHBR+R2AiPgcWAacDeziy0DN7e+vMjiTR/lmXbWlslgPOCyW5rBYmsNiaQ6LpfXl\nbKIkv8VqmIhQt2VcWSzNYbG0VFgkXSrpDUnjku7sd6OsnrqewZU0ArwJXExxeX8TsCIitk2zjo9Z\nGqZXxyznAeMRsTMiPqO4ZL/8SBtnzZMJy3yKy/GTJspp1jI9e+ssaSWwslc/z+onE5Y9wIKO56Pl\ntCkiYjWwGnzMMqwyu6FNwOmSFkmaBVxF0X/VWqZrZYmIQ5JuAsYoeqk/GBFb+94yq52+dH7ybqh5\nfLrfesphsbTGjmGZ1IQ+xFLXCt8IriyW5rBYmsNiaQ6LpTksluawWJrDYmkOi6U5LJbmsFiaw2Jp\nDoulNf5CYpUX6Zpw0bKfXFkszWGxtK5hkbRA0t8lbStvKX5LFQ2z+skMXz0FOCUiXpY0m+IW5Fe0\ncfjqTI9ZmtD5qSd9cCPi3Yh4uXx8ANiORyS20tc6ZpF0KnAOsLEfjbF6S791lvQtiluR3xoR+79i\nvoevDrnUuCFJ36D4cKexiPhdYnkfs3QYlmOWzAGuKD6nZ29E3JrZsMMyVZvCshT4J/Aa8L9y8t0R\n8fQ06zgsHVoTlplwWKYalrD4DK6lOSyW5rBYmsNiaQ6LpTksluawWJrDYmkOi6U5LJbmsFiaw2Jp\nDoulOSyW5rBYWuOHr85UlUNRh6UfjCuLpTkslpYOi6QRSa9IeqqfDbL6+jqV5RaK0YjWUtnPdR4F\nfgKs6W9zrM6yleUB4Jd8ORTEWihzy41lwPsRsaXLcislbZa0uWets1rJDDK7H7gWOAQcA8wB/hIR\n10yzTu3HDTXhll8V3wKtt4PMJP0QuCMilnVZrvZ/CYdlKg8ys55q7fBVV5apXFmspxwWS2vtVeeZ\nlPhhuXo8U64sluawWJrDYmkOi6U5LJbmsFiaw2JpDoulOSyW5rBYmsNiaQ6LpTksluawWJrDYmkO\ni6VlRyQeL+lxSTskbZd0Qb8bZvWT7Sm3Cng2Iq6UNAv4Zh/bZDWVGWQ2F3gVOC2S/Qqb0Lt/Joa5\nW2WvevcvAj4AHipvubFG0nGHL+Thq8MvU1mWABuA70fERkmrgP0Rce8067iydGhTZZkAJiJi8oO/\nHwfOPZKGWTN1DUtEvAfslnRGOelHwLa+tspqKfsh4GdT3MhnFrAT+FlEfDzN8t4NdRiW3VBrxzrP\nRNvD4jO4ltba4asz0YQK0U+uLJbmsFiaw2JpDoulOSyW5rBYmsNiaQ6LpTksluawWJrDYmkOi6U5\nLJbWr6vOHwJvf8X0E8t5VqjL67Ews1BfOj/9341JmyNiSWUbrLmmvR7eDVmaw2JpVYdldcXbq7tG\nvR6VHrNYs3k3ZGmVhUXSpZLekDQu6c6qtltXkt6S9JqkV5syPryS3ZCkEeBN4GKK4bCbgBUR0dqR\njZLeApZERB3Os6RUVVnOA8YjYmdEfAasBZZXtG3rkarCMh/Y3fF8opzWZgE8L2mLpJWDbkyGB5kN\nztKI2CPpJOBvknZExD8G3ajpVFVZ9gALOp6PltNaKyL2lN/fB9ZR7KprraqwbAJOl7SovCfdVcCT\nFW27diQdJ2n25GPgx8Drg21Vd5XshiLikKSbgDFgBHgwIrZWse2aOhlYV46dPhp4JCKeHWyTuvMZ\nXEvzGVxLc1gszWGxNIfF0hwWS3NYLM1hsTSHxdK+ABAq5BGzH/9/AAAAAElFTkSuQmCC\n", 324 | "text/plain": [ 325 | "" 326 | ] 327 | }, 328 | "metadata": {}, 329 | "output_type": "display_data" 330 | } 331 | ], 332 | "source": [ 333 | "plt.figure(figsize=(2,2));\n", 334 | "plt.imshow(seven, interpolation='none');\n", 335 | "plt.grid(False);\n", 336 | "plt.xticks(); plt.yticks();\n", 337 | "plt.title(\"Seven\")" 338 | ] 339 | }, 340 | { 341 | "cell_type": "code", 342 | "execution_count": 16, 343 | "metadata": { 344 | "collapsed": false 345 | }, 346 | "outputs": [ 347 | { 348 | "name": "stderr", 349 | "output_type": "stream", 350 | "text": [ 351 | "/home/gerson/anaconda3/envs/py3/lib/python3.6/site-packages/sklearn/utils/validation.py:395: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.\n", 352 | " DeprecationWarning)\n" 353 | ] 354 | }, 355 | { 356 | "data": { 357 | "text/plain": [ 358 | "array([1])" 359 | ] 360 | }, 361 | "execution_count": 16, 362 | "metadata": {}, 363 | "output_type": "execute_result" 364 | } 365 | ], 366 | "source": [ 367 | "knc.predict(seven.ravel())" 368 | ] 369 | }, 370 | { 371 | "cell_type": "code", 372 | "execution_count": 14, 373 | "metadata": { 374 | "collapsed": false 375 | }, 376 | "outputs": [ 377 | { 378 | "data": { 379 | "text/html": [ 380 | "/* This template is inspired in the one used by Lorena Barba\n", 381 | "in the numerical-mooc repository: https://github.com/numerical-mooc/numerical-mooc\n", 382 | "We thank her work and hope you also enjoy the look of the notobooks with this style */\n", 383 | "\n", 384 | "\n", 385 | "Estilo aplicado\n", 386 | "\n", 526 | "\n" 542 | ], 543 | "text/plain": [ 544 | "" 545 | ] 546 | }, 547 | "execution_count": 14, 548 | "metadata": {}, 549 | "output_type": "execute_result" 550 | } 551 | ], 552 | "source": [ 553 | "# Esta celda da el estilo al notebook\n", 554 | "from IPython.core.display import HTML\n", 555 | "css_file = '../styles/StyleCursoPython.css'\n", 556 | "HTML(open(css_file, \"r\").read())" 557 | ] 558 | } 559 | ], 560 | "metadata": { 561 | "kernelspec": { 562 | "display_name": "Python 3", 563 | "language": "python", 564 | "name": "python3" 565 | }, 566 | "language_info": { 567 | "codemirror_mode": { 568 | "name": "ipython", 569 | "version": 3 570 | }, 571 | "file_extension": ".py", 572 | "mimetype": "text/x-python", 573 | "name": "python", 574 | "nbconvert_exporter": "python", 575 | "pygments_lexer": "ipython3", 576 | "version": "3.6.0" 577 | } 578 | }, 579 | "nbformat": 4, 580 | "nbformat_minor": 2 581 | } 582 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Notebooks/00-Instalación e Introducción.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# Bienvenido al curso de Python Científico\n", 10 | "---------------------\n", 11 | "\n", 12 | "El objetivo de este curso es introducir a los alumnos en la programación en Python desde cero y aprender distintas aplicaciones de este lenguaje en la ciencia e ingeniería.\n", 13 | "\n", 14 | "En este curso vamos a trabajar con los Notebooks de Jupyter, este documento por ejemplo ha sido generado a partir de un notebook. Durante el curso nos familiarizaremos con este entorno y aprenderemos a como usarlo para generar reportes.\n", 15 | "\n", 16 | "Primero veremos los pasos para poder instalar Python, luego instalaremos jupyter.\n", 17 | "\n", 18 | "Si deseas puedes estudiar por cuenta propia visitando nuestro [repositorio](https://github.com/Gerson231294/CursoPython).\n" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "## Empezemos!" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "### 1. Descarga de Python" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "Anaconda es una distribución de Python facil de instalar, que además es un administrador de paquetes necesarios en el ambito de la computación científica, posee una colección de más de 720 paquetes de código abierto que ofrecen soporte de la comunidad libre. No sólo ofrece el notebook sino tambien un IDE muy parecido a MATLAB llamado __spyder__.\n", 40 | "\n", 41 | "Los pasos para la instalación son:\n", 42 | "\n", 43 | "1. Ir a la página de descargas de [Anaconda](https://www.continuum.io/downloads).\n", 44 | " \n", 45 | "2. Seleccionar tu sistema operativo (Windows, OSX, Linux).\n", 46 | "\n", 47 | "3. Descargar Anaconda (utilizaremos Python 3.X)." 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "![Porque usar Python](../images/instalation1.png \"Optional title\")" 55 | ] 56 | }, 57 | { 58 | "cell_type": "markdown", 59 | "metadata": {}, 60 | "source": [ 61 | "### 2. Instalación de Python" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "En __Windows, macOS y Linux__, es mejor instalar Anaconda para el usuario local, que no requiere permisos de administrador y es el tipo de instalación más robusto. Para los usuarios de cualquiera de las tres plataformas que necesiten hacerlo, Anaconda también se puede instalar en todo el sistema, lo que requiere permisos de administrador. \n", 69 | "\n", 70 | "SUGERENCIA: Si no desea que los cientos de paquetes incluidos con Anaconda, puede descargar __Miniconda__, una mini versión de Anaconda que incluye sólo conda, sus dependencias y Python." 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "#### 2.1 Instalación en Windows" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": {}, 83 | "source": [ 84 | "- Descargar el instalador de Anaconda.\n", 85 | "\n", 86 | "- Haga doble clic en el instalador de Anaconda y siga las instrucciones para instalar en la ubicación predeterminada.\n", 87 | "\n", 88 | "- NOTA: Instale Anaconda en una ruta de directorio que no contenga espacios ni caracteres unicode.\n", 89 | "\n", 90 | "- NOTA: No instale como administrador a menos que se requieran privilegios de administrador.\n", 91 | "\n", 92 | "- NOTA: Si encuentra algún problema durante la instalación, desactive temporalmente su software antivirus durante la instalación y, a continuación, vuelva a habilitarlo inmediatamente. Si se ha instalado para todos los usuarios, desinstale Anaconda y vuelva a instalarlo solo para su usuario e inténtelo de nuevo.\n", 93 | "\n", 94 | "- Después de una instalación exitosa verá una salida como esta:" 95 | ] 96 | }, 97 | { 98 | "cell_type": "markdown", 99 | "metadata": {}, 100 | "source": [ 101 | "![Porque usar Python](../images/instalation2.png \"Optional title\")" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": {}, 107 | "source": [ 108 | "#### 2.2 Instalación en Linux\n", 109 | "\n", 110 | "- Descargue el instalador de Anaconda para Linux.\n", 111 | "\n", 112 | "- Abra una ventana de terminal y escriba lo siguiente:\n", 113 | "\n", 114 | "![Porque usar Python](../images/instalation3.png \"Optional title\")\n", 115 | "\n", 116 | "- NOTA: Reemplace ~ / Descargas con su ruta actual y Anaconda3-4.3.0-Linux-x86_64.sh con su nombre de archivo real.\n", 117 | "\n", 118 | "- NOTA: Acepte la ubicación predeterminada o seleccione una ubicación de instalación con permisos de usuario como ~ / anaconda.\n", 119 | "\n", 120 | "- NOTA: Instale Anaconda como un usuario a menos que se requieran privilegios de root.\n", 121 | "\n", 122 | "- Siga las indicaciones en las pantallas del instalador y, si no está seguro acerca de cualquier configuración, simplemente acepte los valores predeterminados, ya que todos pueden cambiarse posteriormente.\n", 123 | "\n", 124 | "- La salida de una instalación exitosa incluirá los mensajes \"Instalación finalizada\" y \"Gracias por instalar Anaconda!\"\n", 125 | "\n", 126 | "- Cierre y vuelva a abrir la ventana de su terminal para que los cambios surtan efecto." 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "metadata": {}, 132 | "source": [ 133 | "### 3. Instalación de Git (Opcional)\n", 134 | "\n", 135 | "Git es un sistema de control de versiones de gran potencia y versatilidad en el manejo de un gran número de archivos de código fuente a a través del desarrollo no lineal, es decir vía la gestión rápida de ramas y mezclado de diferentes versiones.\n", 136 | "\n", 137 | "Github es una plataforma de desarrollo colaborativo de software utilizado para alojar proyectos (muchos proyectos importantes como paquetes de R, Django, el Kernel de Linux, se encuentran alojados ahí) utilizando Git y el framework Ruby on Rails.\n", 138 | "\n", 139 | "Podemos instalar Git en Linux utilizando el administrador de paquetes __apt__:\n", 140 | "\n", 141 | "![Porque usar Python](../images/instalation4.png \"Optional title\")\n", 142 | "\n", 143 | "En Windows vamos a la pagina de [git](https://git-scm.com/download/win) y descargamos: \n", 144 | "\n", 145 | "![Porque usar Python](../images/instalation6.png \"Optional title\")" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "El material del curso está disponible en GitHub, \n", 153 | "\n", 154 | "Simplemente ve a nuestro repositorio del curso en GitHub, y en la parte derecha encontrarás un botón Clone or download como éste:\n", 155 | "\n", 156 | "![Porque usar Python](../images/instalation5.png \"Optional title\")" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "### 4. Abrir el material del curso\n", 164 | ".\n", 165 | "Una vez que instalado Anaconda y descargado el material del curso, para poder utilizarlo debes abrir una línea de comandos en la carpeta que has descomprimido.\n", 166 | "\n", 167 | "En Windows o Linux puedes hacer esto desde el explorador. Primero navega hasta la carpeta y luego usa shift + clic-derecho (Windows) en un espacio vacío de la carpeta y pulsa sobre Abrir ventana de comandos aquí, en linux con click-derecho abrir terminal.\n", 168 | "\n", 169 | "Luego escribimos:\n", 170 | "\n", 171 | "__ jupyter notebook__\n", 172 | "\n", 173 | "y se mostrará una pestaña en su navegador así:\n", 174 | "\n", 175 | "![Porque usar Python](../images/instalation7.png \"Optional title\")" 176 | ] 177 | }, 178 | { 179 | "cell_type": "markdown", 180 | "metadata": {}, 181 | "source": [ 182 | "### 5. ¿Qué es IPython?\n", 183 | "\n", 184 | "IPython es un __shell interactivo__ que añade funcionalidades extra al modo interactivo incluido con Python, como resaltado de líneas y errores mediante colores, una sintaxis adicional para el shell, autocompletado mediante tabulador de variables, módulos y atributos; entre otras funcionalidades.\n", 185 | "\n", 186 | "#### Notebook de IPython\n", 187 | "\n", 188 | "El cuaderno Notebook de IPython está basado en la web y es interactivo. Un notebook en IPython es un documento __JSON__ que contiene una lista ordenada de entradas / salidas las cuales pueden tener __código, texto, imagenes y rich media__. Los notebooks de IPython pueden ser convertidos a otros formatos de archivos como HTML, presentaciones de diapositivas, LaTeX, PDF, Python, etc).\n", 189 | "\n", 190 | "Esta será nuestra herramienta de trabajo durante el curso. Esto que estás leyendo ahora no es más que un notebook de IPython, que como diremos luego además de código puede contener texto e imágenes. Pero veamos primero cómo funciona.\n", 191 | "\n", 192 | "Se puede crear un nuevo cuaderno en cualquier momento, desde el panel de control o mediante la opción de menú Archivo ‣ Nuevo desde un cuaderno activo. El nuevo cuaderno se crea dentro del mismo directorio y se abrirá en una nueva pestaña del navegador. También se reflejará como una nueva entrada en la lista de cuadernos en el dashboard.\n", 193 | "\n", 194 | "![Porque usar Python](../images/markdown0.gif \"Optional title\")\n", 195 | "\n", 196 | "Al crear un notebook o al abrir uno nuevo se abre la interfaz de IPython propiamente dicha donde ya podemos empezar a trabajar. Es similar a un intérprete, pero está dividida en __celdas__. Las celdas pueden contener, código, texto, imágenes...\n", 197 | "\n", 198 | "Cada celda de código está marcada por la palabra __In []__ y están numeradas. Tan solo tenemos que escribir el código en ella y hacer click arriba en Cell -> Run, el triángulo __(\"Run cell\")__ o usar el atajo __shift + Enter__. El resultado de la celda se muestra en el campo __Out []__, también numerado y coincidiendo con la celda que acabamos de ejecutar. Esto es importante, como ya veremos luego.\n", 199 | "\n", 200 | "![Porque usar Python](../images/test1.gif \"Optional title\")\n", 201 | "\n", 202 | "Para documentar nuestros notebooks en IPython esto se logra usando el lenguaje de marcado de texto __Markdown__. Las celdas correspondientes se denominan celdas Markdown. El lenguaje de Markdown proporciona una forma sencilla de realizar este marcado de texto, es decir, especificar qué partes del texto deben enfatizarse (cursivas), negritas, listas de formularios, etc.\n", 203 | "\n", 204 | "Si en la barra superior seleccionas Markdown (o usas el atajo __Shift-M__) en lugar de Code puedes escribir texto: \n", 205 | "\n", 206 | "![Porque usar Python](../images/test2.gif \"Optional title\")\n", 207 | "\n", 208 | "También ecuaciones matematicas en un lenguaje parecido a Latex y mucho más. Esto es una herramienta muy potente para explicar a alguien o a ti mismo lo que tu código hace, para hacer un informe, un trabajo, escribir en un blog...\n", 209 | "\n", 210 | "![Porque usar Python](../images/test3.gif \"Optional title\")\n", 211 | "\n", 212 | "Puedes mover las celdas de un lugar a otro de este modo:\n", 213 | "\n", 214 | "![Porque usar Python](../images/test4.gif \"Optional title\")\n", 215 | "\n", 216 | "El Notebook tiene además numerosos atajos que irás aprendiendo sobre la marcha, puedes consultarlos en Help > Keyboard Shortcourts" 217 | ] 218 | }, 219 | { 220 | "cell_type": "markdown", 221 | "metadata": {}, 222 | "source": [ 223 | "Ahora veremos como podemos ejecutar scripts en nuestro notebook:\n", 224 | "\n", 225 | "Para ver el contenido de nuestro script vamos a usar el comando cat (Linux) para ver el contenido de script1.py." 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 1, 231 | "metadata": {}, 232 | "outputs": [ 233 | { 234 | "name": "stdout", 235 | "output_type": "stream", 236 | "text": [ 237 | "# Bienvenido al curso de Python Científico\n", 238 | "# Esto es un Comentario \n", 239 | "\n", 240 | "a = 4\n", 241 | "b = 5\n", 242 | "\n", 243 | "print(\"Bienvenido al curso de Python\")\n" 244 | ] 245 | } 246 | ], 247 | "source": [ 248 | "!cat script1.py" 249 | ] 250 | }, 251 | { 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "Para ejecutar nuestro script vamos a usar un comado __mágico__ del notebook :" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 2, 261 | "metadata": {}, 262 | "outputs": [ 263 | { 264 | "name": "stdout", 265 | "output_type": "stream", 266 | "text": [ 267 | "Bienvenido al curso de Python\n" 268 | ] 269 | } 270 | ], 271 | "source": [ 272 | "%run script1.py" 273 | ] 274 | }, 275 | { 276 | "cell_type": "markdown", 277 | "metadata": {}, 278 | "source": [ 279 | "Ahora estamos listo para nuestra siguiente [lección](https://github.com/Gerson231294/CursoPython/blob/master/Notebooks/1.%20Python%20-%20Sintaxis.ipynb)! \n" 280 | ] 281 | }, 282 | { 283 | "cell_type": "code", 284 | "execution_count": 3, 285 | "metadata": {}, 286 | "outputs": [ 287 | { 288 | "data": { 289 | "text/html": [ 290 | "/* This template is inspired in the one used by Lorena Barba\n", 291 | "in the numerical-mooc repository: https://github.com/numerical-mooc/numerical-mooc\n", 292 | "We thank her work and hope you also enjoy the look of the notobooks with this style */\n", 293 | "\n", 294 | "\n", 295 | "Estilo aplicado\n", 296 | "\n", 436 | "\n" 452 | ], 453 | "text/plain": [ 454 | "" 455 | ] 456 | }, 457 | "execution_count": 3, 458 | "metadata": {}, 459 | "output_type": "execute_result" 460 | } 461 | ], 462 | "source": [ 463 | "# Esta celda da el estilo al notebook\n", 464 | "from IPython.core.display import HTML\n", 465 | "css_file = '../styles/StyleCursoPython.css'\n", 466 | "HTML(open(css_file, \"r\").read())" 467 | ] 468 | } 469 | ], 470 | "metadata": { 471 | "kernelspec": { 472 | "display_name": "Python 3", 473 | "language": "python", 474 | "name": "python3" 475 | }, 476 | "language_info": { 477 | "codemirror_mode": { 478 | "name": "ipython", 479 | "version": 3 480 | }, 481 | "file_extension": ".py", 482 | "mimetype": "text/x-python", 483 | "name": "python", 484 | "nbconvert_exporter": "python", 485 | "pygments_lexer": "ipython3", 486 | "version": "3.6.3" 487 | } 488 | }, 489 | "nbformat": 4, 490 | "nbformat_minor": 2 491 | } 492 | -------------------------------------------------------------------------------- /Notebooks/06-Archivos, Manejo de Errores & Excepciones.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "deletable": true, 7 | "editable": true 8 | }, 9 | "source": [ 10 | "# 6. Archivos & Manejo de excepciones\n", 11 | "--------------------------------------\n", 12 | "\n", 13 | "## Archivos\n", 14 | "\n", 15 | "Un archivo es información identificada con un nombre que puede ser almacenada de manera permanente en el directorio de un dispositivo. Hasta ahora, hemos estado leyendo y escribiendo en la entrada y salida estándar. Ahora, veremos cómo usar los archivos de datos reales.\n", 16 | "\n", 17 | "Python proporciona funciones y métodos básicos necesarios para manipular archivos de forma predeterminada. Puede realizar la mayor parte de la manipulación de archivos utilizando un objeto de archivo.\n", 18 | "\n", 19 | "\n", 20 | "### Función Open\n", 21 | "\n", 22 | "Antes de poder leer o escribir un archivo, debes abrirlo usando la función open () integrada de Python. Esta función crea un objeto de archivo, que se utilizará para llamar a otros métodos de soporte asociados con él.\n", 23 | "\n", 24 | "** Sintaxis **" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": { 31 | "collapsed": true, 32 | "deletable": true, 33 | "editable": true 34 | }, 35 | "outputs": [], 36 | "source": [ 37 | "file object = open(file_name [, access_mode])" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": { 43 | "deletable": true, 44 | "editable": true 45 | }, 46 | "source": [ 47 | "Aquí están los detalles del parámetro:\n", 48 | "\n", 49 | "* **file_name:** El argumento **file_name** es una cadena que contiene el nombre del archivo al que desea acceder.\n", 50 | "\n", 51 | "* **access_mode:** El modo de acceso determina el modo en el que se debe abrir el archivo, es decir, leer(read), escribir(write), añadir(append), etc. A continuación se muestra una lista completa de valores posibles en la tabla. Este es un parámetro opcional y se lee el modo de acceso de archivo predeterminado (r)\n" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": { 57 | "deletable": true, 58 | "editable": true 59 | }, 60 | "source": [ 61 | "Aquí hay una lista de los diferentes modos de abrir un archivo:" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": { 67 | "collapsed": true, 68 | "deletable": true, 69 | "editable": true 70 | }, 71 | "source": [ 72 | "\n", 73 | "\n", 74 | "\n", 75 | "\n", 76 | "\n", 77 | "\n", 78 | "\n", 79 | "\n", 80 | " \n", 81 | "\n", 82 | " \n", 83 | " \n", 84 | " \n", 85 | "\n", 86 | "
ModosDescripcion
rAbre un archivo sólo para lectura. El puntero del archivo se coloca al principio del archivo. Este es el modo por defecto.
rbAbre un archivo para la lectura sólo en formato binario. El puntero del archivo se coloca al principio del archivo. Este es el modo por defecto.
r+Abre un archivo para leer y escribir. El puntero de archivo colocado al principio del archivo.
rb+Abre un archivo para lectura y escritura en formato binario. El puntero de archivo colocado al principio del archivo.
wAbre un archivo para la escritura solamente. Sobrescribe el archivo si existe el archivo. Si el archivo no existe, crea un nuevo archivo para la escritura.
wbAbre un archivo para escribir sólo en formato binario. Sobrescribe el archivo si existe el archivo. Si el archivo no existe, crea un nuevo archivo para la escritura.
w+Abre un archivo para escribir y leer. Sobreescribe el archivo existente si existe el archivo. Si el archivo no existe, crea un nuevo archivo para leer y escribir.
wb+Abre un archivo para escribir y leer en formato binario. Sobreescribe el archivo existente si existe el archivo. Si el archivo no existe, crea un nuevo archivo para leer y escribir.
aAbre un archivo para agregar. El puntero de archivo está al final del archivo si existe el archivo. Es decir, el archivo está en el modo de agregación. Si el archivo no existe, crea un nuevo archivo para la escritura.
abAbre un archivo para anexar en formato binario. El puntero de archivo está al final del archivo si existe el archivo. Es decir, el archivo está en el modo de agregación. Si el archivo no existe, crea un nuevo archivo para la escritura.
a+Abre un archivo para agregar y leer. El puntero de archivo está al final del archivo si existe el archivo. El archivo se abre en el modo de agregación. Si el archivo no existe, crea un nuevo archivo para leer y escribir.
ab+Abre un archivo para agregar y leer en formato binario. El puntero de archivo está al final del archivo si existe el archivo. El archivo se abre en el modo de agregación. Si el archivo no existe, crea un nuevo archivo para leer y escribir.
" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": { 92 | "collapsed": true, 93 | "deletable": true, 94 | "editable": true 95 | }, 96 | "source": [ 97 | "### Los atributos del objeto File\n" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "metadata": { 103 | "collapsed": true, 104 | "deletable": true, 105 | "editable": true 106 | }, 107 | "source": [ 108 | "Una vez que se abre un archivo y tiene un objeto de archivo, puede obtener información relacionada con ese archivo. \n", 109 | "\n", 110 | "Aquí hay una lista de todos los atributos relacionados con el objeto file:" 111 | ] 112 | }, 113 | { 114 | "cell_type": "markdown", 115 | "metadata": { 116 | "collapsed": true, 117 | "deletable": true, 118 | "editable": true 119 | }, 120 | "source": [ 121 | "\n", 122 | "\n", 123 | "\n", 124 | "\n", 125 | "\n", 126 | "
AtributoDescripción
file.closedDevuelve true si el archivo está cerrado, false de lo contrario.
file.modeDevuelve el modo de acceso con el que se abrió el archivo.
file.nameDevuelve el nombre del archivo.
\n" 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "metadata": { 132 | "collapsed": true, 133 | "deletable": true, 134 | "editable": true 135 | }, 136 | "source": [ 137 | "Ahora veamos un ejemplo:" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 1, 143 | "metadata": { 144 | "collapsed": true, 145 | "deletable": true, 146 | "editable": true 147 | }, 148 | "outputs": [], 149 | "source": [ 150 | "fo = open(\"foo.txt\", \"wb\")" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 2, 156 | "metadata": { 157 | "collapsed": false, 158 | "deletable": true, 159 | "editable": true 160 | }, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | "Name of the file: foo.txt\n", 167 | "Closed or not : False\n", 168 | "Opening mode : wb\n" 169 | ] 170 | } 171 | ], 172 | "source": [ 173 | "print (\"Name of the file: \", fo.name)\n", 174 | "print (\"Closed or not : \", fo.closed)\n", 175 | "print (\"Opening mode : \", fo.mode)\n", 176 | "fo.close() # Método close() OJO METODO NO ATRIBUTO!! NO CONFUNDIR con .closed (atributo)" 177 | ] 178 | }, 179 | { 180 | "cell_type": "markdown", 181 | "metadata": { 182 | "collapsed": true, 183 | "deletable": true, 184 | "editable": true 185 | }, 186 | "source": [ 187 | "### Método close()\n", 188 | "El método **close()** de un objeto de archivo vacía cualquier información no escrita y cierra el objeto de archivo, después de lo cual no se puede realizar más escritura.\n", 189 | "\n", 190 | "Python cierra automáticamente un archivo cuando el objeto de referencia de un archivo se reasigna a otro archivo. Es una buena práctica utilizar el método close () para cerrar un archivo." 191 | ] 192 | }, 193 | { 194 | "cell_type": "markdown", 195 | "metadata": { 196 | "deletable": true, 197 | "editable": true 198 | }, 199 | "source": [ 200 | "### Leyendo y Escribiendo Archivos\n", 201 | "\n", 202 | "El objeto **file** proporciona un conjunto de métodos de acceso para facilitar nuestras vidas. Veremos cómo usar los métodos **read()** y **write()** para leer y escribir archivos.\n", 203 | "\n", 204 | "### Método write()\n", 205 | "El método **write()** escribe cualquier cadena en un archivo abierto. Es importante tener en cuenta que las cadenas de Python pueden tener datos binarios y no sólo texto.\n", 206 | "\n", 207 | "El método write () no agrega un carácter de nueva línea **('\\ n')** al final de la cadena" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 3, 213 | "metadata": { 214 | "collapsed": false, 215 | "deletable": true, 216 | "editable": true 217 | }, 218 | "outputs": [], 219 | "source": [ 220 | "# Copien esto en script, luego de ejecutar se creará un archivo llamado foo1.txt, abránlo y vean la magia ;) \n", 221 | "# Para escribir multiples lineas usen \"\"\"(triples comillas)\"\"\"\n", 222 | "\n", 223 | "# Abriendo un archivo\n", 224 | "fo = open(\"foo1.txt\", \"w\")\n", 225 | "fo.write(\"\"\"Los ordenadores son increíblemente rápidos, precisos, y estúpidos \\n\n", 226 | "Los humanos son increíblemente lentos, imprecisos, y brillantes. \\n\n", 227 | "Juntos, su potencia está más allá de lo imaginable. \"\"\")\n", 228 | "# Cerrando el archivo abierto\n", 229 | "fo.close()" 230 | ] 231 | }, 232 | { 233 | "cell_type": "markdown", 234 | "metadata": { 235 | "deletable": true, 236 | "editable": true 237 | }, 238 | "source": [ 239 | "El método anterior creará el archivo foo.txt y escribirá el contenido dado en ese archivo y finalmente cerrará ese archivo. Si usted abriría este archivo, abŕalo y vea el resultado." 240 | ] 241 | }, 242 | { 243 | "cell_type": "markdown", 244 | "metadata": { 245 | "deletable": true, 246 | "editable": true 247 | }, 248 | "source": [ 249 | "### Método read()\n", 250 | "\n", 251 | "El método **read()** lee una cadena de un archivo abierto. Es importante tener en cuenta que las cadenas de Python pueden tener datos binarios. Aparte de los datos de texto.\n", 252 | "\n", 253 | "En el método read() el parámetro pasado es el número de bytes que se leerán del archivo abierto. Este método comienza a leer desde el principio del archivo y si falta la cuenta, entonces intenta leer tanto como sea posible, tal vez hasta el final del archivo." 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 4, 259 | "metadata": { 260 | "collapsed": false, 261 | "deletable": true, 262 | "editable": true 263 | }, 264 | "outputs": [ 265 | { 266 | "name": "stdout", 267 | "output_type": "stream", 268 | "text": [ 269 | "La cadena leida es : Los ordenadores son \n", 270 | "----------------------------------\n", 271 | "increíblemente rápidos, precisos, y estúpidos \n", 272 | "\n", 273 | "Los humanos son increíblemente lentos, imprecisos, y brillantes. \n", 274 | "\n", 275 | "Juntos, su potencia está más allá de lo imaginable. \n" 276 | ] 277 | } 278 | ], 279 | "source": [ 280 | "# Abriendo el archivo foo1\n", 281 | "fo = open(\"foo1.txt\", \"r+\")\n", 282 | "\n", 283 | "# Le pasamos como argumentos 20 bytes\n", 284 | "str = fo.read(20)\n", 285 | "print (\"La cadena leida es : \", str)\n", 286 | "\n", 287 | "print(\"----------------------------------\")\n", 288 | "\n", 289 | "# Cuando hagamos nuevamente foo.read() leerá los siguientes carácteres despues de haber leido lo demás\n", 290 | "print (fo.read())\n", 291 | "# Cerrando el archivo abierto\n", 292 | "fo.close()" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "metadata": { 298 | "deletable": true, 299 | "editable": true 300 | }, 301 | "source": [ 302 | "### Posición de un archivo\n", 303 | "\n", 304 | "El método **tell()** le indica la posición actual dentro del archivo; En otras palabras, la próxima lectura o escritura se producirá en la posición que este metodo nos indique.\n", 305 | "\n", 306 | "El método **seek(offset [, from])** cambia la posición del archivo actual. El argumento offset indica el número de bytes que se deben mover. El argumento from especifica la posición de referencia desde donde se deben mover los bytes.\n", 307 | "\n", 308 | "Si from está puesto a 0, significa usar el comienzo del archivo como la posición de referencia y 1 significa usar la posición actual como la posición de referencia y si se establece en 2 entonces el final del archivo se tomaría como la posición de referencia ." 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 5, 314 | "metadata": { 315 | "collapsed": false, 316 | "deletable": true, 317 | "editable": true, 318 | "scrolled": false 319 | }, 320 | "outputs": [ 321 | { 322 | "name": "stdout", 323 | "output_type": "stream", 324 | "text": [ 325 | "La cadena leida es: Los ordenadores\n", 326 | "Posición actual del archivo : 15\n", 327 | "Una vez más, la cadena de lectura es: Los ordenadores\n" 328 | ] 329 | } 330 | ], 331 | "source": [ 332 | "# Abriendo un archivo\n", 333 | "fo = open(\"foo1.txt\", \"r+\")\n", 334 | "str = fo.read(15)\n", 335 | "print (\"La cadena leida es: \", str)\n", 336 | "\n", 337 | "# Checkea la posicion actual\n", 338 | "position = fo.tell()\n", 339 | "print (\"Posición actual del archivo : \", position)\n", 340 | "\n", 341 | "# Vuelva a colocar el puntero al principio una vez más\n", 342 | "position = fo.seek(0, 0)\n", 343 | "str = fo.read(15)\n", 344 | "print (\"Una vez más, la cadena de lectura es: \", str)\n", 345 | "# Cerrando el achivo abierto\n", 346 | "fo.close()" 347 | ] 348 | }, 349 | { 350 | "cell_type": "markdown", 351 | "metadata": { 352 | "deletable": true, 353 | "editable": true 354 | }, 355 | "source": [ 356 | "### Ahora veamos un ejemplo del uso de archivos" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": 27, 362 | "metadata": { 363 | "collapsed": false, 364 | "deletable": true, 365 | "editable": true 366 | }, 367 | "outputs": [ 368 | { 369 | "name": "stdout", 370 | "output_type": "stream", 371 | "text": [ 372 | "1. Imprimir los nueros de teléfono\n", 373 | "2. Añade un numero de teléfono\n", 374 | "3. Elimina un numero de teléfono\n", 375 | "4. Busca un numero de teléfono\n", 376 | "5. Carga numeros\n", 377 | "6. Guarda numeros\n", 378 | "7. Salir\n", 379 | "\n", 380 | "Ingrese un numero del (1-7): 1\n", 381 | "Numeros de Telefono:\n", 382 | "\n", 383 | "Ingrese un numero del (1-7): 5\n", 384 | "Archivo a cargar: numeros.txt\n", 385 | "Ingrese un numero del (1-7): 1\n", 386 | "Numeros de Telefono:\n", 387 | "nombre: Carla \t Numero: 912312121\n", 388 | "nombre: Maria \t Numero: 989123876\n", 389 | "\n", 390 | "Ingrese un numero del (1-7): 2\n", 391 | "Ingrese un nombre y un numero\n", 392 | "Nombre: Megumi\n", 393 | "Numero: 908321786\n", 394 | "Ingrese un numero del (1-7): 1\n", 395 | "Numeros de Telefono:\n", 396 | "nombre: Carla \t Numero: 912312121\n", 397 | "nombre: Maria \t Numero: 989123876\n", 398 | "nombre: Megumi \t Numero: 908321786\n", 399 | "\n", 400 | "Ingrese un numero del (1-7): 2\n", 401 | "Ingrese un nombre y un numero\n", 402 | "Nombre: Kosaki\n", 403 | "Numero: 908123867\n", 404 | "Ingrese un numero del (1-7): 3\n", 405 | "Remover el nombre y numero\n", 406 | "Ingrese el nombre que desee eliminar: Carla\n", 407 | "Ingrese un numero del (1-7): 1\n", 408 | "Numeros de Telefono:\n", 409 | "nombre: Maria \t Numero: 989123876\n", 410 | "nombre: Megumi \t Numero: 908321786\n", 411 | "nombre: Kosaki \t Numero: 908123867\n", 412 | "\n", 413 | "Ingrese un numero del (1-7): 4\n", 414 | "Busque un numero\n", 415 | "Nombre: Kosaki\n", 416 | "El numero es 908123867\n", 417 | "Ingrese un numero del (1-7): 6\n", 418 | "Archivo a guardar: numeros2.txt\n", 419 | "Ingrese un numero del (1-7): 7\n", 420 | "Adios :c \n" 421 | ] 422 | } 423 | ], 424 | "source": [ 425 | "# Este programa es una agenda telefónica\n", 426 | "\n", 427 | "# Imprime los nombres y sus respectivos números\n", 428 | "def print_numbers(numbers):\n", 429 | " print(\"Numeros de Telefono:\")\n", 430 | " for k, v in numbers.items():\n", 431 | " print(\"nombre:\", k, \"\\t Numero:\", v)\n", 432 | " print()\n", 433 | "\n", 434 | "# Añande un numero\n", 435 | "def add_number(numbers, name, number):\n", 436 | " numbers[name] = number\n", 437 | "\n", 438 | "# Verifica si un numero se encuentra o no en la agenda\n", 439 | "def lookup_number(numbers, name):\n", 440 | " if name in numbers:\n", 441 | " return \"El numero es \" + numbers[name]\n", 442 | " else:\n", 443 | " return name + \" no ha sido encontrado\"\n", 444 | "\n", 445 | "# Elimina un número\n", 446 | "def remove_number(numbers, name):\n", 447 | " if name in numbers:\n", 448 | " del numbers[name]\n", 449 | " else:\n", 450 | " print(name,\" no ha sido encontrado\")\n", 451 | "\n", 452 | "# Carga números\n", 453 | "def load_numbers(numbers, filename):\n", 454 | " in_file = open(filename, \"rt\")\n", 455 | " while True:\n", 456 | " in_line = in_file.readline()\n", 457 | " if not in_line:\n", 458 | " break\n", 459 | " in_line = in_line[:-1]\n", 460 | " name, number = in_line.split(\",\")\n", 461 | " numbers[name] = number\n", 462 | " in_file.close()\n", 463 | "\n", 464 | "# Guarda numeros\n", 465 | "def save_numbers(numbers, filename):\n", 466 | " out_file = open(filename, \"wt\")\n", 467 | " for k, v in numbers.items():\n", 468 | " out_file.write(k + \",\" + v + \"\\n\")\n", 469 | " out_file.close()\n", 470 | "\n", 471 | "# Menu de inicio\n", 472 | "def print_menu():\n", 473 | " print('1. Imprimir los nueros de teléfono')\n", 474 | " print('2. Añade un numero de teléfono')\n", 475 | " print('3. Elimina un numero de teléfono')\n", 476 | " print('4. Busca un numero de teléfono')\n", 477 | " print('5. Carga numeros')\n", 478 | " print('6. Guarda numeros')\n", 479 | " print('7. Salir')\n", 480 | " print()\n", 481 | "\n", 482 | "# Crea un diccionario vacio\n", 483 | "phone_list = {}\n", 484 | "\n", 485 | "# Inicializa la decicion como 0\n", 486 | "menu_choice = 0\n", 487 | "\n", 488 | "# Inicia el programa\n", 489 | "print_menu()\n", 490 | "\n", 491 | "while True:\n", 492 | " menu_choice = int(input(\"Ingrese un numero del (1-7): \"))\n", 493 | " if menu_choice == 1:\n", 494 | " print_numbers(phone_list)\n", 495 | " elif menu_choice == 2:\n", 496 | " print(\"Ingrese un nombre y un numero\")\n", 497 | " name = input(\"Nombre: \")\n", 498 | " phone = input(\"Numero: \")\n", 499 | " add_number(phone_list, name, phone)\n", 500 | " elif menu_choice == 3:\n", 501 | " print(\"Remover el nombre y numero\")\n", 502 | " name = input(\"Ingrese el nombre que desee eliminar: \")\n", 503 | " remove_number(phone_list, name)\n", 504 | " elif menu_choice == 4:\n", 505 | " print(\"Busque un numero\")\n", 506 | " name = input(\"Nombre: \")\n", 507 | " print(lookup_number(phone_list, name))\n", 508 | " elif menu_choice == 5:\n", 509 | " filename = input(\"Archivo a cargar: \")\n", 510 | " load_numbers(phone_list, filename)\n", 511 | " elif menu_choice == 6:\n", 512 | " filename = input(\"Archivo a guardar: \")\n", 513 | " save_numbers(phone_list, filename)\n", 514 | " elif menu_choice == 7:\n", 515 | " break\n", 516 | " else:\n", 517 | " print_menu()\n", 518 | "\n", 519 | "print(\"Adios :c \")" 520 | ] 521 | }, 522 | { 523 | "cell_type": "markdown", 524 | "metadata": { 525 | "deletable": true, 526 | "editable": true 527 | }, 528 | "source": [ 529 | "Ahora abran el archivo numeros2.txt y vean la magia :O " 530 | ] 531 | }, 532 | { 533 | "cell_type": "markdown", 534 | "metadata": { 535 | "deletable": true, 536 | "editable": true 537 | }, 538 | "source": [ 539 | "## Errores\n", 540 | "\n", 541 | "En un programa podemos encontrarnos con distintos tipos de errores pero a grandes rasgos podemos decir que todos los errores pertenecen a una de las siguientes categorías.\n", 542 | "\n", 543 | "- **Errores de sintaxis:** estos errores son seguramente los más simples de resolver, pues son detectados por el intérprete (o por el compilador, según el tipo de lenguaje que estemos utilizando) al procesar el código fuente y generalmente son consecuencia de equivocaciones al escribir el programa. En el caso de Python estos errores son indicados con un mensaje SyntaxError. Por ejemplo, si trabajando con Python intentamos definir una función y en lugar de def escribimos dev.\n", 544 | "\n", 545 | "- **Errores semánticos:** se dan cuando un programa, a pesar de no generar mensajes de error, no produce el resultado esperado. Esto puede deberse, por ejemplo, a un algoritmo incorrecto o a la omisión de una sentencia.\n", 546 | "\n", 547 | "- **Errores de ejecución:** estos errores aparecen durante la ejecución del programa y su origen puede ser diverso. En ocasiones pueden producirse por un uso incorrecto del programa por parte del usuario, por ejemplo si el usuario ingresa una cadena cuando se espera un número. En otras ocasiones pueden deberse a errores de programación, por ejemplo si una función intenta acceder a la quinta posición de una lista de 3 elementos o realizar una división por cero. Una causa común de errores de ejecución que generalmente excede al programador y al usuario, son los recursos externos al programa, por ejemplo si el programa intenta leer un archivo y el mismo se encuentra dañado.\n", 548 | "\n", 549 | "Tanto a los errores de sintaxis como a los semánticos se los puede detectar y corregir durante la construcción del programa ayudados por el intérprete y la ejecución de pruebas. Pero no ocurre esto con los errores de ejecución ya que no siempre es posible saber cuando ocurrirán y puede resultar muy complejo (o incluso casi imposible) reproducirlos. Es por ello que el resto de la unidad nos centraremos en cómo preparar nuestros programas para lidiar con este tipo de errores." 550 | ] 551 | }, 552 | { 553 | "cell_type": "markdown", 554 | "metadata": { 555 | "deletable": true, 556 | "editable": true 557 | }, 558 | "source": [ 559 | "### Excepciones\n", 560 | "\n", 561 | "Los errores de ejecución son llamados comúnmente excepciones y por eso de ahora en más utilizaremos ese nombre. Durante la ejecución de un programa, si dentro de una función surge una excepción y la función no la maneja, la excepción se propaga hacia la función que la invocó, si esta otra tampoco la maneja, la excepción continua propagándose hasta llegar a la función inicial del programa y si esta tampoco la maneja se interrumpe la ejecución del programa. Veamos entonces como manejar excepciones.\n", 562 | "\n", 563 | "#### Manejo de excepciones\n", 564 | "\n", 565 | "Para el manejo de excepciones los lenguajes proveen ciertas palabras reservadas, que nos permiten manejar las excepciones que puedan surgir y tomar acciones de recuperación para evitar la interrupción del programa o, al menos, para realizar algunas acciones adicionales antes de interrumpir el programa.\n", 566 | "\n", 567 | "En el caso de Python, el manejo de excepciones se hace mediante los bloques que utilizan las sentencias **try**, **except** y **finally**.\n", 568 | "\n", 569 | "Dentro del bloque try se ubica todo el código que pueda llegar a levantar una excepción, se utiliza el término levantar para referirse a la acción de generar una excepción.\n", 570 | "\n", 571 | "A continuación se ubica el bloque except, que se encarga de capturar la excepción y nos da la oportunidad de procesarla mostrando por ejemplo un mensaje adecuado al usuario. Veamos qué sucede si se quiere realizar una división por cero:" 572 | ] 573 | }, 574 | { 575 | "cell_type": "code", 576 | "execution_count": 6, 577 | "metadata": { 578 | "collapsed": false, 579 | "deletable": true, 580 | "editable": true 581 | }, 582 | "outputs": [ 583 | { 584 | "ename": "ZeroDivisionError", 585 | "evalue": "division by zero", 586 | "output_type": "error", 587 | "traceback": [ 588 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 589 | "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", 590 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mdividendo\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m8\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mdivisor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mcociente\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdividendo\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mdivisor\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 591 | "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" 592 | ] 593 | } 594 | ], 595 | "source": [ 596 | "dividendo = 8\n", 597 | "divisor = 0\n", 598 | "cociente = dividendo / divisor" 599 | ] 600 | }, 601 | { 602 | "cell_type": "markdown", 603 | "metadata": { 604 | "deletable": true, 605 | "editable": true 606 | }, 607 | "source": [ 608 | "En este caso, se levantó la excepción **ZeroDivisionError** cuando se quiso hacer la división. Para evitar que se levante la excepción y se detenga la ejecución del programa, se utiliza el bloque **try-except**." 609 | ] 610 | }, 611 | { 612 | "cell_type": "code", 613 | "execution_count": 7, 614 | "metadata": { 615 | "collapsed": false, 616 | "deletable": true, 617 | "editable": true 618 | }, 619 | "outputs": [ 620 | { 621 | "name": "stdout", 622 | "output_type": "stream", 623 | "text": [ 624 | "No se pudo efectuar la division\n" 625 | ] 626 | } 627 | ], 628 | "source": [ 629 | "try:\n", 630 | " cociente = dividendo / divisor\n", 631 | "except:\n", 632 | " print(\"No se pudo efectuar la division\")" 633 | ] 634 | }, 635 | { 636 | "cell_type": "markdown", 637 | "metadata": { 638 | "deletable": true, 639 | "editable": true 640 | }, 641 | "source": [ 642 | "Tambíen podemos capturar multiples excepciones mediante la estrcutura:" 643 | ] 644 | }, 645 | { 646 | "cell_type": "code", 647 | "execution_count": null, 648 | "metadata": { 649 | "collapsed": true, 650 | "deletable": true, 651 | "editable": true 652 | }, 653 | "outputs": [], 654 | "source": [ 655 | "try:\n", 656 | " # aquí ponemos el código que puede lanzar excepciones\n", 657 | "except IOError:\n", 658 | " # entrará aquí en caso que se haya producido una excepción IOError\n", 659 | "except ZeroDivisionError:\n", 660 | " # entrará aquí en caso que se haya producido una excepción ZeroDivisionError\n", 661 | "except: \n", 662 | " # entrará aquí en caso que se haya producido una excepción que no corresponda a ninguno\n", 663 | " # de los tipos especificados en los except previos" 664 | ] 665 | }, 666 | { 667 | "cell_type": "code", 668 | "execution_count": 9, 669 | "metadata": { 670 | "collapsed": false, 671 | "deletable": true, 672 | "editable": true 673 | }, 674 | "outputs": [ 675 | { 676 | "name": "stdout", 677 | "output_type": "stream", 678 | "text": [ 679 | "Ingrese un número: 0\n", 680 | "Pero que el número no sea cero!\n", 681 | "Ingrese un número: 5\n", 682 | "12 / 5 = 2.4\n" 683 | ] 684 | } 685 | ], 686 | "source": [ 687 | "while True:\n", 688 | " try:\n", 689 | " num_str = input('Ingrese un número: ')\n", 690 | " num = int(num_str)\n", 691 | " print(\"{} / {} = {}\".format(12,num, 12/num ))\n", 692 | " break\n", 693 | " except ValueError:\n", 694 | " print('Ingresa un número válido')\n", 695 | " except ZeroDivisionError:\n", 696 | " print('Pero que el número no sea cero!')" 697 | ] 698 | }, 699 | { 700 | "cell_type": "markdown", 701 | "metadata": { 702 | "deletable": true, 703 | "editable": true 704 | }, 705 | "source": [ 706 | "Finalmente, puede ubicarse un bloque **finally** donde se escriben las sentencias de finalización, que son típicamente acciones de limpieza. La particularidad del bloque finally es que se ejecuta siempre, haya surgido una excepción o no. Si hay un bloque except, no es necesario que esté presente el finally, y es posible tener un bloque try sólo con finally, sin except." 707 | ] 708 | }, 709 | { 710 | "cell_type": "code", 711 | "execution_count": 10, 712 | "metadata": { 713 | "collapsed": false, 714 | "deletable": true, 715 | "editable": true 716 | }, 717 | "outputs": [ 718 | { 719 | "name": "stdout", 720 | "output_type": "stream", 721 | "text": [ 722 | "No pude convertir el dato a un entero.\n", 723 | "Ha terminado el bloque\n" 724 | ] 725 | } 726 | ], 727 | "source": [ 728 | "import sys\n", 729 | "\n", 730 | "try:\n", 731 | " f = open('miarchivo.txt')\n", 732 | " s = f.readline()\n", 733 | " i = int(s.strip())\n", 734 | "except OSError as err:\n", 735 | " print(\"Error OS: {0}\".format(err))\n", 736 | "except ValueError:\n", 737 | " print(\"No pude convertir el dato a un entero.\")\n", 738 | "except:\n", 739 | " print(\"Error inesperado:\", sys.exc_info()[0])\n", 740 | "finally:\n", 741 | " print(\"Ha terminado el bloque\")" 742 | ] 743 | }, 744 | { 745 | "cell_type": "markdown", 746 | "metadata": { 747 | "deletable": true, 748 | "editable": true 749 | }, 750 | "source": [ 751 | "### Levantando excepciones" 752 | ] 753 | }, 754 | { 755 | "cell_type": "markdown", 756 | "metadata": { 757 | "deletable": true, 758 | "editable": true 759 | }, 760 | "source": [ 761 | "La declaración **raise** permite al programador forzar a que ocurra una excepción específica. Por ejemplo:" 762 | ] 763 | }, 764 | { 765 | "cell_type": "code", 766 | "execution_count": 11, 767 | "metadata": { 768 | "collapsed": false, 769 | "deletable": true, 770 | "editable": true 771 | }, 772 | "outputs": [ 773 | { 774 | "ename": "NameError", 775 | "evalue": "How you doing?", 776 | "output_type": "error", 777 | "traceback": [ 778 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 779 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", 780 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mNameError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'How you doing?'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 781 | "\u001b[0;31mNameError\u001b[0m: How you doing?" 782 | ] 783 | } 784 | ], 785 | "source": [ 786 | "raise NameError('How you doing?')" 787 | ] 788 | }, 789 | { 790 | "cell_type": "markdown", 791 | "metadata": { 792 | "deletable": true, 793 | "editable": true 794 | }, 795 | "source": [ 796 | "El único argumento a raise indica la excepción a generarse. Tiene que ser o una instancia de excepción, o una clase de excepción (una clase que hereda de Exception).\n", 797 | "\n", 798 | "Si necesitás determinar cuando una excepción fue lanzada pero no querés manejarla, una forma simplificada de la instrucción raise te permite relanzarla:" 799 | ] 800 | }, 801 | { 802 | "cell_type": "code", 803 | "execution_count": 12, 804 | "metadata": { 805 | "collapsed": false, 806 | "deletable": true, 807 | "editable": true 808 | }, 809 | "outputs": [ 810 | { 811 | "name": "stdout", 812 | "output_type": "stream", 813 | "text": [ 814 | "Acaba de ocurrir una excepción!\n" 815 | ] 816 | }, 817 | { 818 | "ename": "NameError", 819 | "evalue": "I am fine", 820 | "output_type": "error", 821 | "traceback": [ 822 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 823 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", 824 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mNameError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'I am fine'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mNameError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Acaba de ocurrir una excepción!'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mraise\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 825 | "\u001b[0;31mNameError\u001b[0m: I am fine" 826 | ] 827 | } 828 | ], 829 | "source": [ 830 | "try:\n", 831 | " raise NameError('I am fine')\n", 832 | "except NameError:\n", 833 | " print('Acaba de ocurrir una excepción!')\n", 834 | " raise" 835 | ] 836 | }, 837 | { 838 | "cell_type": "markdown", 839 | "metadata": { 840 | "deletable": true, 841 | "editable": true 842 | }, 843 | "source": [ 844 | "De más está decir, que las excepciones pueden ser personalizadas según sea necesario:" 845 | ] 846 | }, 847 | { 848 | "cell_type": "code", 849 | "execution_count": 13, 850 | "metadata": { 851 | "collapsed": false, 852 | "deletable": true, 853 | "editable": true 854 | }, 855 | "outputs": [ 856 | { 857 | "name": "stdout", 858 | "output_type": "stream", 859 | "text": [ 860 | "Error creado: Archivos inválidos ('a.conf', 'b.conf')\n" 861 | ] 862 | } 863 | ], 864 | "source": [ 865 | "class MiError(Exception):\n", 866 | " \n", 867 | " def __init__(self, mssg, ref=''):\n", 868 | " self.mssg = mssg\n", 869 | " self.ref = ref\n", 870 | " \n", 871 | " def __str__(self,):\n", 872 | " return \"Error creado: {} {}\".format(self.mssg, self.ref)\n", 873 | " \n", 874 | "try:\n", 875 | " raise MiError(\"Archivos inválidos\", ('a.conf','b.conf') )\n", 876 | "except MiError as e:\n", 877 | " print(e)" 878 | ] 879 | }, 880 | { 881 | "cell_type": "code", 882 | "execution_count": 1, 883 | "metadata": { 884 | "collapsed": false, 885 | "deletable": true, 886 | "editable": true 887 | }, 888 | "outputs": [ 889 | { 890 | "data": { 891 | "text/html": [ 892 | "/* This template is inspired in the one used by Lorena Barba\n", 893 | "in the numerical-mooc repository: https://github.com/numerical-mooc/numerical-mooc\n", 894 | "We thank her work and hope you also enjoy the look of the notobooks with this style */\n", 895 | "\n", 896 | "\n", 897 | "Estilo aplicado\n", 898 | "\n", 1038 | "\n" 1054 | ], 1055 | "text/plain": [ 1056 | "" 1057 | ] 1058 | }, 1059 | "execution_count": 1, 1060 | "metadata": {}, 1061 | "output_type": "execute_result" 1062 | } 1063 | ], 1064 | "source": [ 1065 | "# Esta celda da el estilo al notebook\n", 1066 | "from IPython.core.display import HTML\n", 1067 | "css_file = '../styles/StyleCursoPython.css'\n", 1068 | "HTML(open(css_file, \"r\").read())" 1069 | ] 1070 | } 1071 | ], 1072 | "metadata": { 1073 | "kernelspec": { 1074 | "display_name": "Python 3", 1075 | "language": "python", 1076 | "name": "python3" 1077 | }, 1078 | "language_info": { 1079 | "codemirror_mode": { 1080 | "name": "ipython", 1081 | "version": 3 1082 | }, 1083 | "file_extension": ".py", 1084 | "mimetype": "text/x-python", 1085 | "name": "python", 1086 | "nbconvert_exporter": "python", 1087 | "pygments_lexer": "ipython3", 1088 | "version": "3.6.0" 1089 | } 1090 | }, 1091 | "nbformat": 4, 1092 | "nbformat_minor": 1 1093 | } 1094 | -------------------------------------------------------------------------------- /Notebooks/07-Expresiones Regulares.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 7. Expresiones Regulares\n", 8 | "----------------------------\n", 9 | "\n" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | " Hoy en día el procesamiento de texto se ha convertido en una tarea cotidiana para la programación, para el cerebro humano tal vez esto parezca una tarea trivial pero para las computadoras es dificil detectar que es un número y que es una letra, por ello para que una máquina sea capaz de realizar una busqueda de subcadenas o patrones dentro de otras cadenas de texto de manera eficiente y rápida se usan las __expresiones regulares__.\n", 17 | " \n", 18 | "Las expresiones regulares, también conocidas como __'regex'__ o __'regexp'__, son patrones de búsqueda definidos con una sintaxis formal. Siempre que sigamos sus reglas, podremos realizar búsquedas simples y avanzadas, que utilizadas en conjunto con otras funcionalidades, las vuelven una de las opciones más útiles e importantes de cualquier lenguaje.\n", 19 | "\n", 20 | "Las expresiones regulares en Python pueden ser accedidas usando el módulo __re__, el cual es parte de la biblioteca estándar. Luego de que se haya definido una expresión regular, la función re.match puede ser utilizada para ver si corresponder al principio de una cadena. Si se encuentra una correspondencia, match devuelve un objeto que represente la coincidencia, si no, devuelve __None__." 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "Ejemplo de una expresión regular\n", 28 | "![](https://relopezbriega.github.io/images/regex.png)" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "## Componentes de las Expresiones Regulares\n", 36 | "\n", 37 | "Las expresiones regulares son un mini lenguaje en sí mismo, por lo que para poder utilizarlas eficientemente primero debemos entender los componentes de su sintaxis; ellos son:\n", 38 | "\n", 39 | "* __Literales__: viene a ser una secuencia de caracteres sin significado especial puede ser un conjunto de palabras.\n", 40 | "* __Secuencias de escape__: Las secuencias de escape como en muchos lenguajes de programación como el salto de linea __\\n__ el tabulador __\\t__ y otros\n", 41 | "* __Metacaracteres__: Los metacaracteres son caracteres especiales que son la esencia de las expresiones regulares. \n", 42 | "* __Clases de caracteres__: Se pueden especificar clases de caracteres encerrando una lista de caracteres entre corchetes [], la que que encontrará uno cualquiera de los caracteres de la lista. Si el primer símbolo después del \"[\" es \"^\", la clase encuentra cualquier caracter que no está en la lista.\n", 43 | "\n", 44 | "### Metacaracteres\n", 45 | "\n", 46 | "Se conoce como metacaracteres a aquellos que, dependiendo del contexto, tienen un significado especial para las expresiones regulares. Por lo tanto, los debemos escapar colocándoles una contrabarra () delante para buscarlos explícitamente.\n", 47 | "\n", 48 | "#### Metacaracteres - delimitadores\n", 49 | "Esta clase de metacaracteres nos permite delimitar dónde queremos buscar los patrones de búsqueda. Ellos son\n", 50 | "\n", 51 | "| Metacaracter | Descripciónn |\n", 52 | "| ------------- |:-------------:|\n", 53 | "| ^ | inicio de linea |\n", 54 | "| $ | fin de linea |\n", 55 | "| \\A | inicio de texto |\n", 56 | "| \\Z | fin de texto |\n", 57 | "| . | cualquier caracter en la línea |\n", 58 | "| \\b | encuentra límite de palabra |\n", 59 | "| \\B | encuentra distinto a límite de palabra |\n", 60 | "\n", 61 | "#### Metacaracteres - clases predefinidas\n", 62 | "\n", 63 | "Estas son clases predefinidas que nos facilitan la utilización de las expresiones regulares. Ellos son:\n", 64 | "\n", 65 | "| Metacaracter | Descripciónn |\n", 66 | "| ------------- |:-------------:|\n", 67 | "| \\w | \tun caracter alfanumérico (incluye \"_\") |\n", 68 | "| \\W | un caracter no alfanumérico |\n", 69 | "| \\d | un caracter numérico |\n", 70 | "| \\D | un caracter no numérico |\n", 71 | "| \\s | cualquier espacio (lo mismo que [ \\t\\n\\r\\f]) |\n", 72 | "| \\S | un no espacio |\n", 73 | "\n", 74 | "#### Metacaracteres - iteradores\n", 75 | "\n", 76 | "Cualquier elemento de una expresion regular puede ser seguido por otro tipo de metacaracteres, los iteradores. Usando estos metacaracteres se puede especificar el número de ocurrencias del caracter previo, de un metacaracter o de una subexpresión. Ellos son:\n", 77 | "\n", 78 | "| Metacaracter | Descripciónn |\n", 79 | "| ------------- |:-------------:|\n", 80 | "|* |\tcero o más, similar a {0,}|\n", 81 | "|+ |\tuna o más, similar a {1,}|\n", 82 | "|? |\tcero o una, similar a {0,1}|\n", 83 | "|{n} |\texactamente n veces|\n", 84 | "|{n,} |\tpor lo menos n veces|\n", 85 | "|{n,m} |\tpor lo menos n pero no más de m veces|\n", 86 | "|*? |\tcero o más, similar a {0,}?|\n", 87 | "|+? |\tuna o más, similar a {1,}?|\n", 88 | "|?? |\tcero o una, similar a {0,1}?|\n", 89 | "|{n}? |\texactamente n veces|\n", 90 | "|{n,}? |\tpor lo menos n veces|\n", 91 | "|{n,m}? |\tpor lo menos n pero no más de m veces|\n", 92 | "\n", 93 | "En estos metacaracteres, los dígitos entre llaves de la forma {n,m}, especifican el mínimo número de ocurrencias en n y el máximo en m.\n", 94 | "\n", 95 | "\n" 96 | ] 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "metadata": {}, 101 | "source": [ 102 | "Ahora si empecemos, vamos a usar la librería estandar de Python podemos encontrar el módulo re, el cual nos proporciona todas las operaciones necesarias para trabajar con las expresiones regulares." 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 1, 108 | "metadata": {}, 109 | "outputs": [], 110 | "source": [ 111 | "# importando el modulo de regex de python\n", 112 | "import re " 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "metadata": {}, 118 | "source": [ 119 | "### Ahora vamos a probar buscando cadenas en un string" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 2, 125 | "metadata": {}, 126 | "outputs": [ 127 | { 128 | "name": "stdout", 129 | "output_type": "stream", 130 | "text": [ 131 | "Se ha encontrado la palabra: Python\n", 132 | "<_sre.SRE_Match object; span=(40, 46), match='Python'>\n" 133 | ] 134 | } 135 | ], 136 | "source": [ 137 | "texto = \"Bienvenido al curso de programación con Python\"\n", 138 | "\n", 139 | "palabra = \"Python\"\n", 140 | "res = re.search(palabra, texto)\n", 141 | "\n", 142 | "if res:\n", 143 | " print(\"Se ha encontrado la palabra: \" + palabra)\n", 144 | "else:\n", 145 | " print(\"La palabra: \"+ palabra + \" no se encuentra en el texto\") # En caso de no encontrar nos retornara None\n", 146 | " \n", 147 | "print(res)" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "Vemos que el resultado es un objeto de tipo __Match__, vamos a explorar algunos de sus métodos:" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 3, 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | "40\n", 167 | "46\n", 168 | "(40, 46)\n", 169 | "Bienvenido al curso de programación con Python\n" 170 | ] 171 | } 172 | ], 173 | "source": [ 174 | "print( res.start() ) # Posición donde empieza la coincidencia\n", 175 | "print( res.end() ) # Posición donde termina la coincidencia\n", 176 | "print( res.span() ) # Tupla con posiciones donde empieza y termina la coincidencia\n", 177 | "print( res.string ) # Cadena sobre la que se ha realizado la búsqueda" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 4, 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [ 186 | "texto = \"\"\"\n", 187 | "Hoy en día programar es una carrera entre los ingenieros\n", 188 | "del software intentando construir mayores y mejores programas\n", 189 | "a prueba de idiotas, y el Universo tratando de producir mayores\n", 190 | "y mejores idiotas. Por ahora, el Universo va ganando. \n", 191 | "Rich Cook\n", 192 | "\"\"\"" 193 | ] 194 | }, 195 | { 196 | "cell_type": "markdown", 197 | "metadata": {}, 198 | "source": [ 199 | "Ahora vamos a buscar usando expresiones regulares pero para ello debemos compilar nuestra expresión regular en un __objeto de patrones__ de python:" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 5, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "_sre.SRE_Pattern" 211 | ] 212 | }, 213 | "execution_count": 5, 214 | "metadata": {}, 215 | "output_type": "execute_result" 216 | } 217 | ], 218 | "source": [ 219 | "# compilando la regex\n", 220 | "patron = re.compile(r'\\bUniverso\\b') # busca la palabra Universo\n", 221 | "type(patron)" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": {}, 227 | "source": [ 228 | "Ahora que ya tenemos el objeto de expresión regular compilado podemos utilizar alguno de los siguientes métodos para buscar coincidencias con nuestro texto." 229 | ] 230 | }, 231 | { 232 | "cell_type": "markdown", 233 | "metadata": {}, 234 | "source": [ 235 | "#### Método `match()`\n", 236 | "\n", 237 | "Determina si la regex tiene coincidencias en el comienzo del texto." 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": 6, 243 | "metadata": {}, 244 | "outputs": [ 245 | { 246 | "name": "stdout", 247 | "output_type": "stream", 248 | "text": [ 249 | "None\n" 250 | ] 251 | } 252 | ], 253 | "source": [ 254 | "# match nos devuelve None porque no hubo coincidencia al comienzo del texto\n", 255 | "print(patron.match(texto))" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 7, 261 | "metadata": {}, 262 | "outputs": [ 263 | { 264 | "data": { 265 | "text/plain": [ 266 | "<_sre.SRE_Match object; span=(0, 8), match='Universo'>" 267 | ] 268 | }, 269 | "execution_count": 7, 270 | "metadata": {}, 271 | "output_type": "execute_result" 272 | } 273 | ], 274 | "source": [ 275 | "# match encuentra una coindencia en el comienzo del texto\n", 276 | "t = patron.match('Universo 9 ha sido eliminado')\n", 277 | "t" 278 | ] 279 | }, 280 | { 281 | "cell_type": "markdown", 282 | "metadata": {}, 283 | "source": [ 284 | "#### Método `search()`\n", 285 | "\n", 286 | "Escanea todo el texto buscando cualquier ubicación donde haya una coincidencia." 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": 8, 292 | "metadata": {}, 293 | "outputs": [ 294 | { 295 | "data": { 296 | "text/plain": [ 297 | "<_sre.SRE_Match object; span=(146, 154), match='Universo'>" 298 | ] 299 | }, 300 | "execution_count": 8, 301 | "metadata": {}, 302 | "output_type": "execute_result" 303 | } 304 | ], 305 | "source": [ 306 | "s = patron.search(texto)\n", 307 | "s" 308 | ] 309 | }, 310 | { 311 | "cell_type": "markdown", 312 | "metadata": {}, 313 | "source": [ 314 | "#### Método `findall()`\n", 315 | "\n", 316 | "Encuentra todos los subtextos donde haya una coincidencia y nos devuelve estas coincidencias como una lista." 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": 9, 322 | "metadata": {}, 323 | "outputs": [ 324 | { 325 | "data": { 326 | "text/plain": [ 327 | "['Universo', 'Universo']" 328 | ] 329 | }, 330 | "execution_count": 9, 331 | "metadata": {}, 332 | "output_type": "execute_result" 333 | } 334 | ], 335 | "source": [ 336 | "# findall nos devuelve una lista con todas las coincidencias\n", 337 | "q = patron.findall(texto)\n", 338 | "q" 339 | ] 340 | }, 341 | { 342 | "cell_type": "markdown", 343 | "metadata": {}, 344 | "source": [ 345 | "#### Método `finditer()`\n", 346 | "Es similar al anterior pero en lugar de devolvernos una lista nos devuelve un iterador." 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": 10, 352 | "metadata": {}, 353 | "outputs": [ 354 | { 355 | "data": { 356 | "text/plain": [ 357 | "" 358 | ] 359 | }, 360 | "execution_count": 10, 361 | "metadata": {}, 362 | "output_type": "execute_result" 363 | } 364 | ], 365 | "source": [ 366 | "itera = patron.finditer(texto)\n", 367 | "itera" 368 | ] 369 | }, 370 | { 371 | "cell_type": "code", 372 | "execution_count": 11, 373 | "metadata": { 374 | "scrolled": true 375 | }, 376 | "outputs": [ 377 | { 378 | "data": { 379 | "text/plain": [ 380 | "<_sre.SRE_Match object; span=(146, 154), match='Universo'>" 381 | ] 382 | }, 383 | "execution_count": 11, 384 | "metadata": {}, 385 | "output_type": "execute_result" 386 | } 387 | ], 388 | "source": [ 389 | "# iterando por las distintas coincidencias\n", 390 | "next(itera)" 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "execution_count": 12, 396 | "metadata": {}, 397 | "outputs": [ 398 | { 399 | "data": { 400 | "text/plain": [ 401 | "<_sre.SRE_Match object; span=(217, 225), match='Universo'>" 402 | ] 403 | }, 404 | "execution_count": 12, 405 | "metadata": {}, 406 | "output_type": "execute_result" 407 | } 408 | ], 409 | "source": [ 410 | "next(itera)" 411 | ] 412 | }, 413 | { 414 | "cell_type": "markdown", 415 | "metadata": {}, 416 | "source": [ 417 | "## Modificación de texto mediante el uso de expresiones regulares" 418 | ] 419 | }, 420 | { 421 | "cell_type": "markdown", 422 | "metadata": {}, 423 | "source": [ 424 | "Python nos permite tambien modificar textos mediante el uso de métodos especiales usando expresiones regulares:" 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "execution_count": 13, 430 | "metadata": {}, 431 | "outputs": [], 432 | "source": [ 433 | "# texto de entrada\n", 434 | "poema = \"\"\"Si te sueño porque te quiero,\n", 435 | "si te necesito porque te quiero, \n", 436 | "si te pienso porque te quiero,\n", 437 | "si te añoro porque te quiero,\n", 438 | "¡Te quiero porque te quiero!.\n", 439 | "Y te quiero porque eres tú.\"\"\"" 440 | ] 441 | }, 442 | { 443 | "cell_type": "code", 444 | "execution_count": 14, 445 | "metadata": {}, 446 | "outputs": [], 447 | "source": [ 448 | "# patron para dividir donde no encuentre un caracter alfanumerico\n", 449 | "patron = re.compile(r'\\W+')" 450 | ] 451 | }, 452 | { 453 | "cell_type": "markdown", 454 | "metadata": {}, 455 | "source": [ 456 | "### Método `split()`\n", 457 | "\n", 458 | "Divide el texto en una lista, realizando las divisiones del texto en cada lugar donde se cumple con la expresion regular." 459 | ] 460 | }, 461 | { 462 | "cell_type": "code", 463 | "execution_count": 15, 464 | "metadata": {}, 465 | "outputs": [ 466 | { 467 | "data": { 468 | "text/plain": [ 469 | "['Si',\n", 470 | " 'te',\n", 471 | " 'sueño',\n", 472 | " 'porque',\n", 473 | " 'te',\n", 474 | " 'quiero',\n", 475 | " 'si',\n", 476 | " 'te',\n", 477 | " 'necesito',\n", 478 | " 'porque',\n", 479 | " 'te',\n", 480 | " 'quiero',\n", 481 | " 'si',\n", 482 | " 'te',\n", 483 | " 'pienso',\n", 484 | " 'porque',\n", 485 | " 'te',\n", 486 | " 'quiero',\n", 487 | " 'si',\n", 488 | " 'te',\n", 489 | " 'añoro',\n", 490 | " 'porque',\n", 491 | " 'te',\n", 492 | " 'quiero',\n", 493 | " 'Te',\n", 494 | " 'quiero',\n", 495 | " 'porque',\n", 496 | " 'te',\n", 497 | " 'quiero',\n", 498 | " 'Y',\n", 499 | " 'te',\n", 500 | " 'quiero',\n", 501 | " 'porque',\n", 502 | " 'eres',\n", 503 | " 'tú',\n", 504 | " '']" 505 | ] 506 | }, 507 | "execution_count": 15, 508 | "metadata": {}, 509 | "output_type": "execute_result" 510 | } 511 | ], 512 | "source": [ 513 | "# Vemos que al separar no toma en cuenta las comas ni los signos de puntuación\n", 514 | "# Ya que hemos especificado que solo tome en cuenta los caracteres alfanumericos\n", 515 | "palabras = patron.split(poema)\n", 516 | "palabras" 517 | ] 518 | }, 519 | { 520 | "cell_type": "code", 521 | "execution_count": 16, 522 | "metadata": {}, 523 | "outputs": [ 524 | { 525 | "data": { 526 | "text/plain": [ 527 | "['Si te sueño porque te quiero,',\n", 528 | " 'si te necesito porque te quiero, ',\n", 529 | " 'si te pienso porque te quiero,',\n", 530 | " 'si te añoro porque te quiero,',\n", 531 | " '¡Te quiero porque te quiero!.',\n", 532 | " 'Y te quiero porque eres tú.']" 533 | ] 534 | }, 535 | "execution_count": 16, 536 | "metadata": {}, 537 | "output_type": "execute_result" 538 | } 539 | ], 540 | "source": [ 541 | "# Utilizando la version no compilada de split.\n", 542 | "re.split(r'\\n', poema) # Dividiendo por linea." 543 | ] 544 | }, 545 | { 546 | "cell_type": "markdown", 547 | "metadata": {}, 548 | "source": [ 549 | "### Método `sub()`\n", 550 | "\n", 551 | "Encuentra todos los subtextos donde existe una coincidencia con la expresion regular y luego los reemplaza con un nuevo texto." 552 | ] 553 | }, 554 | { 555 | "cell_type": "code", 556 | "execution_count": 17, 557 | "metadata": {}, 558 | "outputs": [ 559 | { 560 | "name": "stdout", 561 | "output_type": "stream", 562 | "text": [ 563 | "Si te sueño porque me gustas,\n", 564 | "si te necesito porque me gustas, \n", 565 | "si te pienso porque me gustas,\n", 566 | "si te añoro porque me gustas,\n", 567 | "¡me gustas porque me gustas!.\n", 568 | "Y me gustas porque eres tú.\n" 569 | ] 570 | } 571 | ], 572 | "source": [ 573 | "# Cambiando \"Te quiero\" o \"te quiero\" por \"me gustas\"\n", 574 | "old = re.compile(r'\\b(T|t)e quiero\\b')\n", 575 | "cambio = old.sub(\"me gustas\", poema)\n", 576 | "print(cambio)" 577 | ] 578 | }, 579 | { 580 | "cell_type": "markdown", 581 | "metadata": {}, 582 | "source": [ 583 | "## Ahora veamos el uso de los metacaracteres con iteradores" 584 | ] 585 | }, 586 | { 587 | "cell_type": "code", 588 | "execution_count": 18, 589 | "metadata": {}, 590 | "outputs": [], 591 | "source": [ 592 | "# Nuestra función nos ayudará a encontrar las palabras que cumplan con nuestro patron\n", 593 | "\n", 594 | "def encuentra_patron(lista, frase):\n", 595 | " \n", 596 | " for item in lista:\n", 597 | " print ('Buscando la frase: %r' %item)\n", 598 | " print (re.findall(item, frase))\n", 599 | " print ('\\n')" 600 | ] 601 | }, 602 | { 603 | "cell_type": "code", 604 | "execution_count": 19, 605 | "metadata": {}, 606 | "outputs": [], 607 | "source": [ 608 | "frase = 'aHaH.. aaaHHH... aHHHaHHH...HaHa...maaaaa...aHHHH'" 609 | ] 610 | }, 611 | { 612 | "cell_type": "code", 613 | "execution_count": 20, 614 | "metadata": {}, 615 | "outputs": [], 616 | "source": [ 617 | "lista_patrones = [ 'aH*', # a seguido de cero o más H\n", 618 | " 'aH+', # a seguido por una o más H\n", 619 | " 'aH?', # a seguido por cero o un H\n", 620 | " 'aH{3}', # a seguido por tres H\n", 621 | " 'aH{2,3}', # a seguido por dos a tres H\n", 622 | " ]" 623 | ] 624 | }, 625 | { 626 | "cell_type": "code", 627 | "execution_count": 21, 628 | "metadata": { 629 | "scrolled": true 630 | }, 631 | "outputs": [ 632 | { 633 | "name": "stdout", 634 | "output_type": "stream", 635 | "text": [ 636 | "Buscando la frase: 'aH*'\n", 637 | "['aH', 'aH', 'a', 'a', 'aHHH', 'aHHH', 'aHHH', 'aH', 'a', 'a', 'a', 'a', 'a', 'a', 'aHHHH']\n", 638 | "\n", 639 | "\n", 640 | "Buscando la frase: 'aH+'\n", 641 | "['aH', 'aH', 'aHHH', 'aHHH', 'aHHH', 'aH', 'aHHHH']\n", 642 | "\n", 643 | "\n", 644 | "Buscando la frase: 'aH?'\n", 645 | "['aH', 'aH', 'a', 'a', 'aH', 'aH', 'aH', 'aH', 'a', 'a', 'a', 'a', 'a', 'a', 'aH']\n", 646 | "\n", 647 | "\n", 648 | "Buscando la frase: 'aH{3}'\n", 649 | "['aHHH', 'aHHH', 'aHHH', 'aHHH']\n", 650 | "\n", 651 | "\n", 652 | "Buscando la frase: 'aH{2,3}'\n", 653 | "['aHHH', 'aHHH', 'aHHH', 'aHHH']\n", 654 | "\n", 655 | "\n" 656 | ] 657 | } 658 | ], 659 | "source": [ 660 | "encuentra_patron(lista_patrones, frase)" 661 | ] 662 | }, 663 | { 664 | "cell_type": "code", 665 | "execution_count": 22, 666 | "metadata": {}, 667 | "outputs": [], 668 | "source": [ 669 | "frase = 'La vida Puede sEr muy Dificil, Pero siemPre Tienes quE Levantarte y Seguir Adelante'\n", 670 | "\n", 671 | "lista_patrones2 = [ '[a-z]+', # Secuencia de letras minusculas\n", 672 | " '[A-Z]+', # Secuencia de letras mayusculas\n", 673 | " '[a-zA-Z]+', # Secuencia de letras minusculas y mayusculas \n", 674 | " '[A-Z][a-z]+'] # Palabras con letra mayuscula seguida de una letra minuscula" 675 | ] 676 | }, 677 | { 678 | "cell_type": "code", 679 | "execution_count": 23, 680 | "metadata": {}, 681 | "outputs": [ 682 | { 683 | "name": "stdout", 684 | "output_type": "stream", 685 | "text": [ 686 | "Buscando la frase: '[a-z]+'\n", 687 | "['a', 'vida', 'uede', 's', 'r', 'muy', 'ificil', 'ero', 'siem', 're', 'ienes', 'qu', 'evantarte', 'y', 'eguir', 'delante']\n", 688 | "\n", 689 | "\n", 690 | "Buscando la frase: '[A-Z]+'\n", 691 | "['L', 'P', 'E', 'D', 'P', 'P', 'T', 'E', 'L', 'S', 'A']\n", 692 | "\n", 693 | "\n", 694 | "Buscando la frase: '[a-zA-Z]+'\n", 695 | "['La', 'vida', 'Puede', 'sEr', 'muy', 'Dificil', 'Pero', 'siemPre', 'Tienes', 'quE', 'Levantarte', 'y', 'Seguir', 'Adelante']\n", 696 | "\n", 697 | "\n", 698 | "Buscando la frase: '[A-Z][a-z]+'\n", 699 | "['La', 'Puede', 'Er', 'Dificil', 'Pero', 'Pre', 'Tienes', 'Levantarte', 'Seguir', 'Adelante']\n", 700 | "\n", 701 | "\n" 702 | ] 703 | } 704 | ], 705 | "source": [ 706 | "encuentra_patron(lista_patrones2, frase)" 707 | ] 708 | }, 709 | { 710 | "cell_type": "markdown", 711 | "metadata": { 712 | "collapsed": true 713 | }, 714 | "source": [ 715 | "## Veamos algunos ejemplos" 716 | ] 717 | }, 718 | { 719 | "cell_type": "markdown", 720 | "metadata": {}, 721 | "source": [ 722 | "### 1. Validando que el campo ingresado sea un correo" 723 | ] 724 | }, 725 | { 726 | "cell_type": "code", 727 | "execution_count": 24, 728 | "metadata": {}, 729 | "outputs": [], 730 | "source": [ 731 | "# compilando la regex\n", 732 | "correo = re.compile(r'\\b[\\w.%+-]+@[\\w.-]+\\.[a-zA-Z]{2,6}\\b') # busca los correos" 733 | ] 734 | }, 735 | { 736 | "cell_type": "code", 737 | "execution_count": 31, 738 | "metadata": {}, 739 | "outputs": [ 740 | { 741 | "name": "stdout", 742 | "output_type": "stream", 743 | "text": [ 744 | "Ingrese su correo:hola\n", 745 | "El correo ingresado es incorrecto\n", 746 | "Ingrese su correo:hola@test.com\n", 747 | "Bienvenido\n" 748 | ] 749 | } 750 | ], 751 | "source": [ 752 | "while True:\n", 753 | " correo_input = input(\"Ingrese su correo:\")\n", 754 | " if(correo.match(correo_input)):\n", 755 | " print(\"Bienvenido\")\n", 756 | " break\n", 757 | " else:\n", 758 | " print(\"El correo ingresado es incorrecto\")" 759 | ] 760 | }, 761 | { 762 | "cell_type": "markdown", 763 | "metadata": { 764 | "collapsed": true 765 | }, 766 | "source": [ 767 | "### 2. Validando que las URL sean https" 768 | ] 769 | }, 770 | { 771 | "cell_type": "code", 772 | "execution_count": 26, 773 | "metadata": {}, 774 | "outputs": [ 775 | { 776 | "name": "stdout", 777 | "output_type": "stream", 778 | "text": [ 779 | "<_sre.SRE_Match object; span=(0, 41), match='https://github.com/gersongams/CursoPython'>\n" 780 | ] 781 | } 782 | ], 783 | "source": [ 784 | "# Validando una URL\n", 785 | "url = re.compile(r\"^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$\")\n", 786 | "\n", 787 | "# vemos que https://github.com/gersongams/CursoPython lo acepta como una url válida.\n", 788 | "print(url.search(\"https://github.com/gersongams/CursoPython\"))" 789 | ] 790 | }, 791 | { 792 | "cell_type": "code", 793 | "execution_count": 27, 794 | "metadata": {}, 795 | "outputs": [ 796 | { 797 | "name": "stdout", 798 | "output_type": "stream", 799 | "text": [ 800 | "None\n" 801 | ] 802 | } 803 | ], 804 | "source": [ 805 | "# Veamos si funciona con\n", 806 | "print(url.search(\"https://github.com/gersongams/This?is?A?URL\"))" 807 | ] 808 | }, 809 | { 810 | "cell_type": "markdown", 811 | "metadata": {}, 812 | "source": [ 813 | "### 3. Validando una dirección IP" 814 | ] 815 | }, 816 | { 817 | "cell_type": "code", 818 | "execution_count": 28, 819 | "metadata": {}, 820 | "outputs": [], 821 | "source": [ 822 | "# Validando una dirección IP\n", 823 | "patron = ('^(?:(?:25[0-5]|2[0-4][0-9]|'\n", 824 | " '[01]?[0-9][0-9]?)\\.){3}'\n", 825 | " '(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')\n", 826 | "\n", 827 | "ip = re.compile(patron)\n", 828 | "\n", 829 | "listaIP = [\"255.255.255.255\",\n", 830 | " \"256.0.0.255\",\n", 831 | " \"192.168.12.51\",\n", 832 | " \"0.0.0.1\",\n", 833 | " \"182.156.256.1\"\n", 834 | " \"1.0.0.0\",\n", 835 | " \"255.256.1.1\"]" 836 | ] 837 | }, 838 | { 839 | "cell_type": "code", 840 | "execution_count": 29, 841 | "metadata": {}, 842 | "outputs": [ 843 | { 844 | "name": "stdout", 845 | "output_type": "stream", 846 | "text": [ 847 | "255.255.255.255 Es una ip correcta\n", 848 | "256.0.0.255 Es una ip incorrecta\n", 849 | "192.168.12.51 Es una ip correcta\n", 850 | "0.0.0.1 Es una ip correcta\n", 851 | "182.156.256.11.0.0.0 Es una ip incorrecta\n", 852 | "255.256.1.1 Es una ip incorrecta\n" 853 | ] 854 | } 855 | ], 856 | "source": [ 857 | "for item in listaIP:\n", 858 | " if(ip.match(item)):\n", 859 | " print(item + \" Es una ip correcta\")\n", 860 | " else:\n", 861 | " print(item + \" Es una ip incorrecta\")" 862 | ] 863 | }, 864 | { 865 | "cell_type": "markdown", 866 | "metadata": {}, 867 | "source": [ 868 | "Este material es una adaptación del blog de: \n", 869 | "\n", 870 | "https://relopezbriega.github.io/blog/2015/07/19/expresiones-regulares-con-python/" 871 | ] 872 | }, 873 | { 874 | "cell_type": "code", 875 | "execution_count": 30, 876 | "metadata": {}, 877 | "outputs": [ 878 | { 879 | "data": { 880 | "text/html": [ 881 | "\n", 882 | "Estilo aplicado\n", 883 | "\n", 1023 | "\n" 1039 | ], 1040 | "text/plain": [ 1041 | "" 1042 | ] 1043 | }, 1044 | "execution_count": 30, 1045 | "metadata": {}, 1046 | "output_type": "execute_result" 1047 | } 1048 | ], 1049 | "source": [ 1050 | "# Esta celda da el estilo al notebook\n", 1051 | "from IPython.core.display import HTML\n", 1052 | "css_file = '../styles/StyleCursoPython.css'\n", 1053 | "HTML(open(css_file, \"r\").read())" 1054 | ] 1055 | } 1056 | ], 1057 | "metadata": { 1058 | "kernelspec": { 1059 | "display_name": "Python 3", 1060 | "language": "python", 1061 | "name": "python3" 1062 | }, 1063 | "language_info": { 1064 | "codemirror_mode": { 1065 | "name": "ipython", 1066 | "version": 3 1067 | }, 1068 | "file_extension": ".py", 1069 | "mimetype": "text/x-python", 1070 | "name": "python", 1071 | "nbconvert_exporter": "python", 1072 | "pygments_lexer": "ipython3", 1073 | "version": "3.6.5" 1074 | } 1075 | }, 1076 | "nbformat": 4, 1077 | "nbformat_minor": 1 1078 | } 1079 | -------------------------------------------------------------------------------- /Notebooks/filename.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/Notebooks/filename.png -------------------------------------------------------------------------------- /Notebooks/foo.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/Notebooks/foo.txt -------------------------------------------------------------------------------- /Notebooks/foo1.txt: -------------------------------------------------------------------------------- 1 | Los ordenadores son increíblemente rápidos, precisos, y estúpidos 2 | 3 | Los humanos son increíblemente lentos, imprecisos, y brillantes. 4 | 5 | Juntos, su potencia está más allá de lo imaginable. -------------------------------------------------------------------------------- /Notebooks/miarchivo.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/Notebooks/miarchivo.txt -------------------------------------------------------------------------------- /Notebooks/numeros.txt: -------------------------------------------------------------------------------- 1 | Maria,989123876 2 | Carla,912312121 3 | -------------------------------------------------------------------------------- /Notebooks/numeros2.txt: -------------------------------------------------------------------------------- 1 | Maria,989123876 2 | Megumi,908321786 3 | Kosaki,908123867 4 | -------------------------------------------------------------------------------- /Notebooks/script1.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/Notebooks/script1.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Curso de Python Científico 2 | 3 | En este repositorio se encuentra el material del curso de Python Cientifico impartido por estudiantes de CS de la Universidad Nacional de Ingeniería. 4 | 5 |

6 | 7 |

8 | 9 | 10 | __Para ver los notebooks:__ Haga click sobre los notebooks que se encuentran debajo para observarlos en (http://nbviewer.jupyter.org/) 11 | 12 | También puede interactuar con los notebooks de manera online usando el siguiente enlance: [![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/gersongams/CursoPython/master) 13 | 14 | https://mybinder.org/v2/gh/gersongams/CursoPython/master 15 | 16 | ## ¿Cómo usar este material? 17 | 18 | Lee la guía de [instalación](http://nbviewer.jupyter.org/github/Gerson231294/CursoPython/blob/master/Notebooks/0.%20Instalaci%C3%B3n%20e%20Introducci%C3%B3n.ipynb). 19 | 20 | * Clonar o descargar este material 21 | ```bash 22 | git clone https://github.com/gersongams/CursoPython 23 | ``` 24 | * Abrir los notebooks desde consola usando el comando: 25 | ```bash 26 | cd CursoPython/ 27 | jupyter notebook 28 | ``` 29 | Esto abrirá una nueva página en tu navegador con los notebooks disponibles. 30 | 31 | ## Temario 32 | 33 | ### Python Básico 34 | 35 | * [00. Instalación e Introducción](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/00-Instalaci%C3%B3n%20e%20Introducci%C3%B3n.ipynb) 36 | * [01. Python - Sintaxis](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/01-Python%20-%20Sintaxis.ipynb) 37 | * [02. Estructuras de control y Bucles](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/02-Contro%20de%20Flujo%20y%20Bucles.ipynb) 38 | * [03. Colecciones](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/03-Colecciones%20en%20Python.ipynb) 39 | * [04. Funciones](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/04-Funciones.ipynb) 40 | * [05. Programación Orientada a Objetos](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/05-Programacion%20orientada%20a%20objetos.ipynb) 41 | * [06. Archivos & Manejo de Excepciones](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/06-Archivos%2C%20Manejo%20de%20Errores%20%26%20Excepciones.ipynb) 42 | * [07. Expresiones Regulares](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/07-Expresiones%20Regulares.ipynb) 43 | 44 | ### Python Científico 45 | 46 | * [8. Numpy](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/08-Numpy%20-%20Introducci%C3%B3n.ipynb) 47 | * [9. Matplotlib](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/09-Matplotlib.ipynb) 48 | * [10. Sympy](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/10-Sympy.ipynb) 49 | * [11. Pandas](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/11-Pandas.ipynb) 50 | * [12. Scipy](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/12-Scipy.ipynb) 51 | * [13. Scikit-Learn](http://nbviewer.jupyter.org/github/gersongams/CursoPython/blob/master/Notebooks/13-Scikit-Learn.ipynb) 52 | 53 | ## Lista de librerías usadas en el curso: 54 | 55 | * [NumPy](http://www.numpy.org/), es la biblioteca natural para python numérico. La característica más potente de NumPy es la matriz n-dimensional. Esta biblioteca contiene funciones básicas de álgebra lineal, transformadas de Fourier, capacidades avanzadas de números aleatorios y herramientas para la integración con otros lenguajes de bajo nivel como Fortran, C y C ++. 56 | 57 | * [SciPy](https://www.scipy.org/) es la biblioeteca para python científico. SciPy se basa en NumPy y es una de las bibliotecas más útiles por la variedad de módulos de ciencia y ingeniería de alto nivel con la que cuenta, como la transformada discreta de Fourier, álgebra lineal, optimización, matrices dispersas, etc. 58 | 59 | * [Pandas](http://pandas.pydata.org/) es una librería para operaciones y manipulaciones de datos estructurados. Pandas ha sido añadido recientemente a Python y han sido fundamental para impulsar el uso de Python en la ciencia de datos. 60 | 61 | * [Matplotlib](http://matplotlib.org/) es una librería de Python para crear una gran variedad de gráficos, a partir de histogramas, lineas, etc, usando si es necesario comandos de látex para agregar matemáticas a los gráficos. 62 | 63 | * [Seaborn](https://seaborn.pydata.org/) es una libreria para la visualización de datos estadísticos. Seaborn es una biblioteca para hacer atractivos e informativos los gráficos estadísticos en Python. Se basa en matplotlib. Seaborn pretende hacer de la visualización una parte central de la exploración y la comprensión de los datos. 64 | 65 | * [SymPy](https://simpy.readthedocs.io/en/latest/) es una biblioteca para la computación simbólica. Tiene amplias capacidades desde la aritmética simbólica básica hasta el cálculo, el álgebra, la matemática discreta y la física cuántica. Otra característica útil es la capacidad de formatear el resultado de los cálculos como código LaTeX. 66 | 67 | * [Scikit-learn](http://scikit-learn.org/stable/), es tal vez la mejor biblioteca para Machine Learning, construida sobre NumPy, SciPy y Matplotlib, esta biblioteca contiene una gran cantidad de herramientas eficientes para el Machine Learning y el modelado estadístico incluyendo clasificación, regresión, agrupación y reducción de la dimensionalidad. 68 | 69 | ## ¿Cómo colaborar? 70 | Si deseas, puedes colaborar añadiendo algunos ejemplos, problemas, etc. Para ello debes: 71 | 72 | * Hacer un fork de este proyecto 73 | * Hacer un pull request a este repositorio 74 | 75 | ## Autor 76 | * [@gersongams](https://github.com/gersongams) 77 | 78 | ## Referencias 79 | - https://docs.python.org/3.6/tutorial/ 80 | - Sweigart, A. (2015). Automate the Boring Stuff with Python: Practical Programming for Total Beginners. No Starch Press. 81 | - Matthes, E. (2015). Python Crash Course: A Hands-on, Project-based Introduction to Programming. No Starch Press. 82 | - https://github.com/Kyubyong/numpy_exercises 83 | - http://www.labri.fr/perso/nrougier/teaching/numpy/numpy.html 84 | - https://github.com/jrjohansson/scientific-python-lectures 85 | - https://stanford.edu/~arbenson/cme193.html 86 | -------------------------------------------------------------------------------- /data/50_Startups.csv: -------------------------------------------------------------------------------- 1 | R&D Spend,Administration,Marketing Spend,State,Profit 2 | 165349.2,136897.8,471784.1,New York,192261.83 3 | 162597.7,151377.59,443898.53,California,191792.06 4 | 153441.51,101145.55,407934.54,Florida,191050.39 5 | 144372.41,118671.85,383199.62,New York,182901.99 6 | 142107.34,91391.77,366168.42,Florida,166187.94 7 | 131876.9,99814.71,362861.36,New York,156991.12 8 | 134615.46,147198.87,127716.82,California,156122.51 9 | 130298.13,145530.06,323876.68,Florida,155752.6 10 | 120542.52,148718.95,311613.29,New York,152211.77 11 | 123334.88,108679.17,304981.62,California,149759.96 12 | 101913.08,110594.11,229160.95,Florida,146121.95 13 | 100671.96,91790.61,249744.55,California,144259.4 14 | 93863.75,127320.38,249839.44,Florida,141585.52 15 | 91992.39,135495.07,252664.93,California,134307.35 16 | 119943.24,156547.42,256512.92,Florida,132602.65 17 | 114523.61,122616.84,261776.23,New York,129917.04 18 | 78013.11,121597.55,264346.06,California,126992.93 19 | 94657.16,145077.58,282574.31,New York,125370.37 20 | 91749.16,114175.79,294919.57,Florida,124266.9 21 | 86419.7,153514.11,0,New York,122776.86 22 | 76253.86,113867.3,298664.47,California,118474.03 23 | 78389.47,153773.43,299737.29,New York,111313.02 24 | 73994.56,122782.75,303319.26,Florida,110352.25 25 | 67532.53,105751.03,304768.73,Florida,108733.99 26 | 77044.01,99281.34,140574.81,New York,108552.04 27 | 64664.71,139553.16,137962.62,California,107404.34 28 | 75328.87,144135.98,134050.07,Florida,105733.54 29 | 72107.6,127864.55,353183.81,New York,105008.31 30 | 66051.52,182645.56,118148.2,Florida,103282.38 31 | 65605.48,153032.06,107138.38,New York,101004.64 32 | 61994.48,115641.28,91131.24,Florida,99937.59 33 | 61136.38,152701.92,88218.23,New York,97483.56 34 | 63408.86,129219.61,46085.25,California,97427.84 35 | 55493.95,103057.49,214634.81,Florida,96778.92 36 | 46426.07,157693.92,210797.67,California,96712.8 37 | 46014.02,85047.44,205517.64,New York,96479.51 38 | 28663.76,127056.21,201126.82,Florida,90708.19 39 | 44069.95,51283.14,197029.42,California,89949.14 40 | 20229.59,65947.93,185265.1,New York,81229.06 41 | 38558.51,82982.09,174999.3,California,81005.76 42 | 28754.33,118546.05,172795.67,California,78239.91 43 | 27892.92,84710.77,164470.71,Florida,77798.83 44 | 23640.93,96189.63,148001.11,California,71498.49 45 | 15505.73,127382.3,35534.17,New York,69758.98 46 | 22177.74,154806.14,28334.72,California,65200.33 47 | 1000.23,124153.04,1903.93,New York,64926.08 48 | 1315.46,115816.21,297114.46,Florida,49490.75 49 | 0,135426.92,0,California,42559.73 50 | 542.05,51743.15,0,New York,35673.41 51 | 0,116983.8,45173.06,California,14681.4 -------------------------------------------------------------------------------- /data/Data.csv: -------------------------------------------------------------------------------- 1 | Country,Age,Salary,Purchased 2 | France,44,72000,No 3 | Spain,27,48000,Yes 4 | Germany,30,54000,No 5 | Spain,38,61000,No 6 | Germany,40,,Yes 7 | France,35,58000,Yes 8 | Spain,,52000,No 9 | France,48,79000,Yes 10 | Germany,50,83000,No 11 | France,37,67000,Yes -------------------------------------------------------------------------------- /data/Mall_Customers.csv: -------------------------------------------------------------------------------- 1 | CustomerID,Genre,Age,Annual Income (k$),Spending Score (1-100) 2 | 0001,Male,19,15,39 3 | 0002,Male,21,15,81 4 | 0003,Female,20,16,6 5 | 0004,Female,23,16,77 6 | 0005,Female,31,17,40 7 | 0006,Female,22,17,76 8 | 0007,Female,35,18,6 9 | 0008,Female,23,18,94 10 | 0009,Male,64,19,3 11 | 0010,Female,30,19,72 12 | 0011,Male,67,19,14 13 | 0012,Female,35,19,99 14 | 0013,Female,58,20,15 15 | 0014,Female,24,20,77 16 | 0015,Male,37,20,13 17 | 0016,Male,22,20,79 18 | 0017,Female,35,21,35 19 | 0018,Male,20,21,66 20 | 0019,Male,52,23,29 21 | 0020,Female,35,23,98 22 | 0021,Male,35,24,35 23 | 0022,Male,25,24,73 24 | 0023,Female,46,25,5 25 | 0024,Male,31,25,73 26 | 0025,Female,54,28,14 27 | 0026,Male,29,28,82 28 | 0027,Female,45,28,32 29 | 0028,Male,35,28,61 30 | 0029,Female,40,29,31 31 | 0030,Female,23,29,87 32 | 0031,Male,60,30,4 33 | 0032,Female,21,30,73 34 | 0033,Male,53,33,4 35 | 0034,Male,18,33,92 36 | 0035,Female,49,33,14 37 | 0036,Female,21,33,81 38 | 0037,Female,42,34,17 39 | 0038,Female,30,34,73 40 | 0039,Female,36,37,26 41 | 0040,Female,20,37,75 42 | 0041,Female,65,38,35 43 | 0042,Male,24,38,92 44 | 0043,Male,48,39,36 45 | 0044,Female,31,39,61 46 | 0045,Female,49,39,28 47 | 0046,Female,24,39,65 48 | 0047,Female,50,40,55 49 | 0048,Female,27,40,47 50 | 0049,Female,29,40,42 51 | 0050,Female,31,40,42 52 | 0051,Female,49,42,52 53 | 0052,Male,33,42,60 54 | 0053,Female,31,43,54 55 | 0054,Male,59,43,60 56 | 0055,Female,50,43,45 57 | 0056,Male,47,43,41 58 | 0057,Female,51,44,50 59 | 0058,Male,69,44,46 60 | 0059,Female,27,46,51 61 | 0060,Male,53,46,46 62 | 0061,Male,70,46,56 63 | 0062,Male,19,46,55 64 | 0063,Female,67,47,52 65 | 0064,Female,54,47,59 66 | 0065,Male,63,48,51 67 | 0066,Male,18,48,59 68 | 0067,Female,43,48,50 69 | 0068,Female,68,48,48 70 | 0069,Male,19,48,59 71 | 0070,Female,32,48,47 72 | 0071,Male,70,49,55 73 | 0072,Female,47,49,42 74 | 0073,Female,60,50,49 75 | 0074,Female,60,50,56 76 | 0075,Male,59,54,47 77 | 0076,Male,26,54,54 78 | 0077,Female,45,54,53 79 | 0078,Male,40,54,48 80 | 0079,Female,23,54,52 81 | 0080,Female,49,54,42 82 | 0081,Male,57,54,51 83 | 0082,Male,38,54,55 84 | 0083,Male,67,54,41 85 | 0084,Female,46,54,44 86 | 0085,Female,21,54,57 87 | 0086,Male,48,54,46 88 | 0087,Female,55,57,58 89 | 0088,Female,22,57,55 90 | 0089,Female,34,58,60 91 | 0090,Female,50,58,46 92 | 0091,Female,68,59,55 93 | 0092,Male,18,59,41 94 | 0093,Male,48,60,49 95 | 0094,Female,40,60,40 96 | 0095,Female,32,60,42 97 | 0096,Male,24,60,52 98 | 0097,Female,47,60,47 99 | 0098,Female,27,60,50 100 | 0099,Male,48,61,42 101 | 0100,Male,20,61,49 102 | 0101,Female,23,62,41 103 | 0102,Female,49,62,48 104 | 0103,Male,67,62,59 105 | 0104,Male,26,62,55 106 | 0105,Male,49,62,56 107 | 0106,Female,21,62,42 108 | 0107,Female,66,63,50 109 | 0108,Male,54,63,46 110 | 0109,Male,68,63,43 111 | 0110,Male,66,63,48 112 | 0111,Male,65,63,52 113 | 0112,Female,19,63,54 114 | 0113,Female,38,64,42 115 | 0114,Male,19,64,46 116 | 0115,Female,18,65,48 117 | 0116,Female,19,65,50 118 | 0117,Female,63,65,43 119 | 0118,Female,49,65,59 120 | 0119,Female,51,67,43 121 | 0120,Female,50,67,57 122 | 0121,Male,27,67,56 123 | 0122,Female,38,67,40 124 | 0123,Female,40,69,58 125 | 0124,Male,39,69,91 126 | 0125,Female,23,70,29 127 | 0126,Female,31,70,77 128 | 0127,Male,43,71,35 129 | 0128,Male,40,71,95 130 | 0129,Male,59,71,11 131 | 0130,Male,38,71,75 132 | 0131,Male,47,71,9 133 | 0132,Male,39,71,75 134 | 0133,Female,25,72,34 135 | 0134,Female,31,72,71 136 | 0135,Male,20,73,5 137 | 0136,Female,29,73,88 138 | 0137,Female,44,73,7 139 | 0138,Male,32,73,73 140 | 0139,Male,19,74,10 141 | 0140,Female,35,74,72 142 | 0141,Female,57,75,5 143 | 0142,Male,32,75,93 144 | 0143,Female,28,76,40 145 | 0144,Female,32,76,87 146 | 0145,Male,25,77,12 147 | 0146,Male,28,77,97 148 | 0147,Male,48,77,36 149 | 0148,Female,32,77,74 150 | 0149,Female,34,78,22 151 | 0150,Male,34,78,90 152 | 0151,Male,43,78,17 153 | 0152,Male,39,78,88 154 | 0153,Female,44,78,20 155 | 0154,Female,38,78,76 156 | 0155,Female,47,78,16 157 | 0156,Female,27,78,89 158 | 0157,Male,37,78,1 159 | 0158,Female,30,78,78 160 | 0159,Male,34,78,1 161 | 0160,Female,30,78,73 162 | 0161,Female,56,79,35 163 | 0162,Female,29,79,83 164 | 0163,Male,19,81,5 165 | 0164,Female,31,81,93 166 | 0165,Male,50,85,26 167 | 0166,Female,36,85,75 168 | 0167,Male,42,86,20 169 | 0168,Female,33,86,95 170 | 0169,Female,36,87,27 171 | 0170,Male,32,87,63 172 | 0171,Male,40,87,13 173 | 0172,Male,28,87,75 174 | 0173,Male,36,87,10 175 | 0174,Male,36,87,92 176 | 0175,Female,52,88,13 177 | 0176,Female,30,88,86 178 | 0177,Male,58,88,15 179 | 0178,Male,27,88,69 180 | 0179,Male,59,93,14 181 | 0180,Male,35,93,90 182 | 0181,Female,37,97,32 183 | 0182,Female,32,97,86 184 | 0183,Male,46,98,15 185 | 0184,Female,29,98,88 186 | 0185,Female,41,99,39 187 | 0186,Male,30,99,97 188 | 0187,Female,54,101,24 189 | 0188,Male,28,101,68 190 | 0189,Female,41,103,17 191 | 0190,Female,36,103,85 192 | 0191,Female,34,103,23 193 | 0192,Female,32,103,69 194 | 0193,Male,33,113,8 195 | 0194,Female,38,113,91 196 | 0195,Female,47,120,16 197 | 0196,Female,35,120,79 198 | 0197,Female,45,126,28 199 | 0198,Male,32,126,74 200 | 0199,Male,32,137,18 201 | 0200,Male,30,137,83 -------------------------------------------------------------------------------- /data/Position_Salaries.csv: -------------------------------------------------------------------------------- 1 | Position,Level,Salary 2 | Business Analyst,1,45000 3 | Junior Consultant,2,50000 4 | Senior Consultant,3,60000 5 | Manager,4,80000 6 | Country Manager,5,110000 7 | Region Manager,6,150000 8 | Partner,7,200000 9 | Senior Partner,8,300000 10 | C-level,9,500000 11 | CEO,10,1000000 -------------------------------------------------------------------------------- /data/Salary_Data.csv: -------------------------------------------------------------------------------- 1 | YearsExperience,Salary 2 | 1.1,39343.00 3 | 1.3,46205.00 4 | 1.5,37731.00 5 | 2.0,43525.00 6 | 2.2,39891.00 7 | 2.9,56642.00 8 | 3.0,60150.00 9 | 3.2,54445.00 10 | 3.2,64445.00 11 | 3.7,57189.00 12 | 3.9,63218.00 13 | 4.0,55794.00 14 | 4.0,56957.00 15 | 4.1,57081.00 16 | 4.5,61111.00 17 | 4.9,67938.00 18 | 5.1,66029.00 19 | 5.3,83088.00 20 | 5.9,81363.00 21 | 6.0,93940.00 22 | 6.8,91738.00 23 | 7.1,98273.00 24 | 7.9,101302.00 25 | 8.2,113812.00 26 | 8.7,109431.00 27 | 9.0,105582.00 28 | 9.5,116969.00 29 | 9.6,112635.00 30 | 10.3,122391.00 31 | 10.5,121872.00 32 | -------------------------------------------------------------------------------- /data/Social_Network_Ads.csv: -------------------------------------------------------------------------------- 1 | User ID,Gender,Age,EstimatedSalary,Purchased 2 | 15624510,Male,19,19000,0 3 | 15810944,Male,35,20000,0 4 | 15668575,Female,26,43000,0 5 | 15603246,Female,27,57000,0 6 | 15804002,Male,19,76000,0 7 | 15728773,Male,27,58000,0 8 | 15598044,Female,27,84000,0 9 | 15694829,Female,32,150000,1 10 | 15600575,Male,25,33000,0 11 | 15727311,Female,35,65000,0 12 | 15570769,Female,26,80000,0 13 | 15606274,Female,26,52000,0 14 | 15746139,Male,20,86000,0 15 | 15704987,Male,32,18000,0 16 | 15628972,Male,18,82000,0 17 | 15697686,Male,29,80000,0 18 | 15733883,Male,47,25000,1 19 | 15617482,Male,45,26000,1 20 | 15704583,Male,46,28000,1 21 | 15621083,Female,48,29000,1 22 | 15649487,Male,45,22000,1 23 | 15736760,Female,47,49000,1 24 | 15714658,Male,48,41000,1 25 | 15599081,Female,45,22000,1 26 | 15705113,Male,46,23000,1 27 | 15631159,Male,47,20000,1 28 | 15792818,Male,49,28000,1 29 | 15633531,Female,47,30000,1 30 | 15744529,Male,29,43000,0 31 | 15669656,Male,31,18000,0 32 | 15581198,Male,31,74000,0 33 | 15729054,Female,27,137000,1 34 | 15573452,Female,21,16000,0 35 | 15776733,Female,28,44000,0 36 | 15724858,Male,27,90000,0 37 | 15713144,Male,35,27000,0 38 | 15690188,Female,33,28000,0 39 | 15689425,Male,30,49000,0 40 | 15671766,Female,26,72000,0 41 | 15782806,Female,27,31000,0 42 | 15764419,Female,27,17000,0 43 | 15591915,Female,33,51000,0 44 | 15772798,Male,35,108000,0 45 | 15792008,Male,30,15000,0 46 | 15715541,Female,28,84000,0 47 | 15639277,Male,23,20000,0 48 | 15798850,Male,25,79000,0 49 | 15776348,Female,27,54000,0 50 | 15727696,Male,30,135000,1 51 | 15793813,Female,31,89000,0 52 | 15694395,Female,24,32000,0 53 | 15764195,Female,18,44000,0 54 | 15744919,Female,29,83000,0 55 | 15671655,Female,35,23000,0 56 | 15654901,Female,27,58000,0 57 | 15649136,Female,24,55000,0 58 | 15775562,Female,23,48000,0 59 | 15807481,Male,28,79000,0 60 | 15642885,Male,22,18000,0 61 | 15789109,Female,32,117000,0 62 | 15814004,Male,27,20000,0 63 | 15673619,Male,25,87000,0 64 | 15595135,Female,23,66000,0 65 | 15583681,Male,32,120000,1 66 | 15605000,Female,59,83000,0 67 | 15718071,Male,24,58000,0 68 | 15679760,Male,24,19000,0 69 | 15654574,Female,23,82000,0 70 | 15577178,Female,22,63000,0 71 | 15595324,Female,31,68000,0 72 | 15756932,Male,25,80000,0 73 | 15726358,Female,24,27000,0 74 | 15595228,Female,20,23000,0 75 | 15782530,Female,33,113000,0 76 | 15592877,Male,32,18000,0 77 | 15651983,Male,34,112000,1 78 | 15746737,Male,18,52000,0 79 | 15774179,Female,22,27000,0 80 | 15667265,Female,28,87000,0 81 | 15655123,Female,26,17000,0 82 | 15595917,Male,30,80000,0 83 | 15668385,Male,39,42000,0 84 | 15709476,Male,20,49000,0 85 | 15711218,Male,35,88000,0 86 | 15798659,Female,30,62000,0 87 | 15663939,Female,31,118000,1 88 | 15694946,Male,24,55000,0 89 | 15631912,Female,28,85000,0 90 | 15768816,Male,26,81000,0 91 | 15682268,Male,35,50000,0 92 | 15684801,Male,22,81000,0 93 | 15636428,Female,30,116000,0 94 | 15809823,Male,26,15000,0 95 | 15699284,Female,29,28000,0 96 | 15786993,Female,29,83000,0 97 | 15709441,Female,35,44000,0 98 | 15710257,Female,35,25000,0 99 | 15582492,Male,28,123000,1 100 | 15575694,Male,35,73000,0 101 | 15756820,Female,28,37000,0 102 | 15766289,Male,27,88000,0 103 | 15593014,Male,28,59000,0 104 | 15584545,Female,32,86000,0 105 | 15675949,Female,33,149000,1 106 | 15672091,Female,19,21000,0 107 | 15801658,Male,21,72000,0 108 | 15706185,Female,26,35000,0 109 | 15789863,Male,27,89000,0 110 | 15720943,Male,26,86000,0 111 | 15697997,Female,38,80000,0 112 | 15665416,Female,39,71000,0 113 | 15660200,Female,37,71000,0 114 | 15619653,Male,38,61000,0 115 | 15773447,Male,37,55000,0 116 | 15739160,Male,42,80000,0 117 | 15689237,Male,40,57000,0 118 | 15679297,Male,35,75000,0 119 | 15591433,Male,36,52000,0 120 | 15642725,Male,40,59000,0 121 | 15701962,Male,41,59000,0 122 | 15811613,Female,36,75000,0 123 | 15741049,Male,37,72000,0 124 | 15724423,Female,40,75000,0 125 | 15574305,Male,35,53000,0 126 | 15678168,Female,41,51000,0 127 | 15697020,Female,39,61000,0 128 | 15610801,Male,42,65000,0 129 | 15745232,Male,26,32000,0 130 | 15722758,Male,30,17000,0 131 | 15792102,Female,26,84000,0 132 | 15675185,Male,31,58000,0 133 | 15801247,Male,33,31000,0 134 | 15725660,Male,30,87000,0 135 | 15638963,Female,21,68000,0 136 | 15800061,Female,28,55000,0 137 | 15578006,Male,23,63000,0 138 | 15668504,Female,20,82000,0 139 | 15687491,Male,30,107000,1 140 | 15610403,Female,28,59000,0 141 | 15741094,Male,19,25000,0 142 | 15807909,Male,19,85000,0 143 | 15666141,Female,18,68000,0 144 | 15617134,Male,35,59000,0 145 | 15783029,Male,30,89000,0 146 | 15622833,Female,34,25000,0 147 | 15746422,Female,24,89000,0 148 | 15750839,Female,27,96000,1 149 | 15749130,Female,41,30000,0 150 | 15779862,Male,29,61000,0 151 | 15767871,Male,20,74000,0 152 | 15679651,Female,26,15000,0 153 | 15576219,Male,41,45000,0 154 | 15699247,Male,31,76000,0 155 | 15619087,Female,36,50000,0 156 | 15605327,Male,40,47000,0 157 | 15610140,Female,31,15000,0 158 | 15791174,Male,46,59000,0 159 | 15602373,Male,29,75000,0 160 | 15762605,Male,26,30000,0 161 | 15598840,Female,32,135000,1 162 | 15744279,Male,32,100000,1 163 | 15670619,Male,25,90000,0 164 | 15599533,Female,37,33000,0 165 | 15757837,Male,35,38000,0 166 | 15697574,Female,33,69000,0 167 | 15578738,Female,18,86000,0 168 | 15762228,Female,22,55000,0 169 | 15614827,Female,35,71000,0 170 | 15789815,Male,29,148000,1 171 | 15579781,Female,29,47000,0 172 | 15587013,Male,21,88000,0 173 | 15570932,Male,34,115000,0 174 | 15794661,Female,26,118000,0 175 | 15581654,Female,34,43000,0 176 | 15644296,Female,34,72000,0 177 | 15614420,Female,23,28000,0 178 | 15609653,Female,35,47000,0 179 | 15594577,Male,25,22000,0 180 | 15584114,Male,24,23000,0 181 | 15673367,Female,31,34000,0 182 | 15685576,Male,26,16000,0 183 | 15774727,Female,31,71000,0 184 | 15694288,Female,32,117000,1 185 | 15603319,Male,33,43000,0 186 | 15759066,Female,33,60000,0 187 | 15814816,Male,31,66000,0 188 | 15724402,Female,20,82000,0 189 | 15571059,Female,33,41000,0 190 | 15674206,Male,35,72000,0 191 | 15715160,Male,28,32000,0 192 | 15730448,Male,24,84000,0 193 | 15662067,Female,19,26000,0 194 | 15779581,Male,29,43000,0 195 | 15662901,Male,19,70000,0 196 | 15689751,Male,28,89000,0 197 | 15667742,Male,34,43000,0 198 | 15738448,Female,30,79000,0 199 | 15680243,Female,20,36000,0 200 | 15745083,Male,26,80000,0 201 | 15708228,Male,35,22000,0 202 | 15628523,Male,35,39000,0 203 | 15708196,Male,49,74000,0 204 | 15735549,Female,39,134000,1 205 | 15809347,Female,41,71000,0 206 | 15660866,Female,58,101000,1 207 | 15766609,Female,47,47000,0 208 | 15654230,Female,55,130000,1 209 | 15794566,Female,52,114000,0 210 | 15800890,Female,40,142000,1 211 | 15697424,Female,46,22000,0 212 | 15724536,Female,48,96000,1 213 | 15735878,Male,52,150000,1 214 | 15707596,Female,59,42000,0 215 | 15657163,Male,35,58000,0 216 | 15622478,Male,47,43000,0 217 | 15779529,Female,60,108000,1 218 | 15636023,Male,49,65000,0 219 | 15582066,Male,40,78000,0 220 | 15666675,Female,46,96000,0 221 | 15732987,Male,59,143000,1 222 | 15789432,Female,41,80000,0 223 | 15663161,Male,35,91000,1 224 | 15694879,Male,37,144000,1 225 | 15593715,Male,60,102000,1 226 | 15575002,Female,35,60000,0 227 | 15622171,Male,37,53000,0 228 | 15795224,Female,36,126000,1 229 | 15685346,Male,56,133000,1 230 | 15691808,Female,40,72000,0 231 | 15721007,Female,42,80000,1 232 | 15794253,Female,35,147000,1 233 | 15694453,Male,39,42000,0 234 | 15813113,Male,40,107000,1 235 | 15614187,Male,49,86000,1 236 | 15619407,Female,38,112000,0 237 | 15646227,Male,46,79000,1 238 | 15660541,Male,40,57000,0 239 | 15753874,Female,37,80000,0 240 | 15617877,Female,46,82000,0 241 | 15772073,Female,53,143000,1 242 | 15701537,Male,42,149000,1 243 | 15736228,Male,38,59000,0 244 | 15780572,Female,50,88000,1 245 | 15769596,Female,56,104000,1 246 | 15586996,Female,41,72000,0 247 | 15722061,Female,51,146000,1 248 | 15638003,Female,35,50000,0 249 | 15775590,Female,57,122000,1 250 | 15730688,Male,41,52000,0 251 | 15753102,Female,35,97000,1 252 | 15810075,Female,44,39000,0 253 | 15723373,Male,37,52000,0 254 | 15795298,Female,48,134000,1 255 | 15584320,Female,37,146000,1 256 | 15724161,Female,50,44000,0 257 | 15750056,Female,52,90000,1 258 | 15609637,Female,41,72000,0 259 | 15794493,Male,40,57000,0 260 | 15569641,Female,58,95000,1 261 | 15815236,Female,45,131000,1 262 | 15811177,Female,35,77000,0 263 | 15680587,Male,36,144000,1 264 | 15672821,Female,55,125000,1 265 | 15767681,Female,35,72000,0 266 | 15600379,Male,48,90000,1 267 | 15801336,Female,42,108000,1 268 | 15721592,Male,40,75000,0 269 | 15581282,Male,37,74000,0 270 | 15746203,Female,47,144000,1 271 | 15583137,Male,40,61000,0 272 | 15680752,Female,43,133000,0 273 | 15688172,Female,59,76000,1 274 | 15791373,Male,60,42000,1 275 | 15589449,Male,39,106000,1 276 | 15692819,Female,57,26000,1 277 | 15727467,Male,57,74000,1 278 | 15734312,Male,38,71000,0 279 | 15764604,Male,49,88000,1 280 | 15613014,Female,52,38000,1 281 | 15759684,Female,50,36000,1 282 | 15609669,Female,59,88000,1 283 | 15685536,Male,35,61000,0 284 | 15750447,Male,37,70000,1 285 | 15663249,Female,52,21000,1 286 | 15638646,Male,48,141000,0 287 | 15734161,Female,37,93000,1 288 | 15631070,Female,37,62000,0 289 | 15761950,Female,48,138000,1 290 | 15649668,Male,41,79000,0 291 | 15713912,Female,37,78000,1 292 | 15586757,Male,39,134000,1 293 | 15596522,Male,49,89000,1 294 | 15625395,Male,55,39000,1 295 | 15760570,Male,37,77000,0 296 | 15566689,Female,35,57000,0 297 | 15725794,Female,36,63000,0 298 | 15673539,Male,42,73000,1 299 | 15705298,Female,43,112000,1 300 | 15675791,Male,45,79000,0 301 | 15747043,Male,46,117000,1 302 | 15736397,Female,58,38000,1 303 | 15678201,Male,48,74000,1 304 | 15720745,Female,37,137000,1 305 | 15637593,Male,37,79000,1 306 | 15598070,Female,40,60000,0 307 | 15787550,Male,42,54000,0 308 | 15603942,Female,51,134000,0 309 | 15733973,Female,47,113000,1 310 | 15596761,Male,36,125000,1 311 | 15652400,Female,38,50000,0 312 | 15717893,Female,42,70000,0 313 | 15622585,Male,39,96000,1 314 | 15733964,Female,38,50000,0 315 | 15753861,Female,49,141000,1 316 | 15747097,Female,39,79000,0 317 | 15594762,Female,39,75000,1 318 | 15667417,Female,54,104000,1 319 | 15684861,Male,35,55000,0 320 | 15742204,Male,45,32000,1 321 | 15623502,Male,36,60000,0 322 | 15774872,Female,52,138000,1 323 | 15611191,Female,53,82000,1 324 | 15674331,Male,41,52000,0 325 | 15619465,Female,48,30000,1 326 | 15575247,Female,48,131000,1 327 | 15695679,Female,41,60000,0 328 | 15713463,Male,41,72000,0 329 | 15785170,Female,42,75000,0 330 | 15796351,Male,36,118000,1 331 | 15639576,Female,47,107000,1 332 | 15693264,Male,38,51000,0 333 | 15589715,Female,48,119000,1 334 | 15769902,Male,42,65000,0 335 | 15587177,Male,40,65000,0 336 | 15814553,Male,57,60000,1 337 | 15601550,Female,36,54000,0 338 | 15664907,Male,58,144000,1 339 | 15612465,Male,35,79000,0 340 | 15810800,Female,38,55000,0 341 | 15665760,Male,39,122000,1 342 | 15588080,Female,53,104000,1 343 | 15776844,Male,35,75000,0 344 | 15717560,Female,38,65000,0 345 | 15629739,Female,47,51000,1 346 | 15729908,Male,47,105000,1 347 | 15716781,Female,41,63000,0 348 | 15646936,Male,53,72000,1 349 | 15768151,Female,54,108000,1 350 | 15579212,Male,39,77000,0 351 | 15721835,Male,38,61000,0 352 | 15800515,Female,38,113000,1 353 | 15591279,Male,37,75000,0 354 | 15587419,Female,42,90000,1 355 | 15750335,Female,37,57000,0 356 | 15699619,Male,36,99000,1 357 | 15606472,Male,60,34000,1 358 | 15778368,Male,54,70000,1 359 | 15671387,Female,41,72000,0 360 | 15573926,Male,40,71000,1 361 | 15709183,Male,42,54000,0 362 | 15577514,Male,43,129000,1 363 | 15778830,Female,53,34000,1 364 | 15768072,Female,47,50000,1 365 | 15768293,Female,42,79000,0 366 | 15654456,Male,42,104000,1 367 | 15807525,Female,59,29000,1 368 | 15574372,Female,58,47000,1 369 | 15671249,Male,46,88000,1 370 | 15779744,Male,38,71000,0 371 | 15624755,Female,54,26000,1 372 | 15611430,Female,60,46000,1 373 | 15774744,Male,60,83000,1 374 | 15629885,Female,39,73000,0 375 | 15708791,Male,59,130000,1 376 | 15793890,Female,37,80000,0 377 | 15646091,Female,46,32000,1 378 | 15596984,Female,46,74000,0 379 | 15800215,Female,42,53000,0 380 | 15577806,Male,41,87000,1 381 | 15749381,Female,58,23000,1 382 | 15683758,Male,42,64000,0 383 | 15670615,Male,48,33000,1 384 | 15715622,Female,44,139000,1 385 | 15707634,Male,49,28000,1 386 | 15806901,Female,57,33000,1 387 | 15775335,Male,56,60000,1 388 | 15724150,Female,49,39000,1 389 | 15627220,Male,39,71000,0 390 | 15672330,Male,47,34000,1 391 | 15668521,Female,48,35000,1 392 | 15807837,Male,48,33000,1 393 | 15592570,Male,47,23000,1 394 | 15748589,Female,45,45000,1 395 | 15635893,Male,60,42000,1 396 | 15757632,Female,39,59000,0 397 | 15691863,Female,46,41000,1 398 | 15706071,Male,51,23000,1 399 | 15654296,Female,50,20000,1 400 | 15755018,Male,36,33000,0 401 | 15594041,Female,49,36000,1 -------------------------------------------------------------------------------- /data/children_heights.txt: -------------------------------------------------------------------------------- 1 | Boys_2 Boys_9 Boys_18 Girls_2 Girls_9 Girls_18 2 | 90.2 139.4 179 83.8 136.5 169.6 3 | 91.4 144.3 195.1 86.2 137 166.8 4 | 86.4 136.5 183.7 85.1 129 157.1 5 | 87.6 135.4 178.7 88.6 139.4 181.1 6 | 86.7 128.9 171.5 83 125.6 158.4 7 | 88.1 136 181.8 88.9 137.1 165.6 8 | 82.2 128.5 172.5 89.7 133.6 166.7 9 | 83.8 133.2 174.6 81.3 121.4 156.5 10 | 91 145.6 190.4 88.7 133.6 168.1 11 | 87.4 132.4 173.8 88.4 134.1 165.3 12 | 84.2 133.7 172.6 85.1 139.4 163.7 13 | 88.4 138.3 185.2 91.4 138.1 173.7 14 | 87.7 134.6 178.4 86.1 138.4 169.2 15 | 89.6 139 177.6 94 139.5 170.1 16 | 91.4 146 183.5 82.2 129.8 164.2 17 | 90 133.2 178.1 88.2 144.8 176 18 | 86.4 133.3 177 87.5 138.9 170.9 19 | 90 130.3 172.9 88.6 140.3 169.2 20 | 91.4 144.5 188.4 86.9 143.8 172 21 | 81.3 125.4 169.4 86.4 133.6 163 22 | 90.6 135.8 180.2 80.9 123.5 154.5 23 | 92.2 139.9 189 90 139.9 172.5 24 | 87.1 136.8 182.4 94 136.1 175.6 25 | 91.4 140.6 185.8 89.7 135.8 167.2 26 | 89.7 138.6 180.7 86.4 131.9 164 27 | 92.2 140 178.7 86.4 130.9 161.6 28 | 81.8 126.3 153.6 29 | 91.4 135.5 173.5 30 | 88.6 134 166.2 31 | 86.4 138.2 162.8 32 | 94 142 168.6 33 | 89.2 140.8 169.2 34 | -------------------------------------------------------------------------------- /images/Lenna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/Lenna.png -------------------------------------------------------------------------------- /images/array.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/array.gif -------------------------------------------------------------------------------- /images/array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/array.png -------------------------------------------------------------------------------- /images/cars.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/cars.jpg -------------------------------------------------------------------------------- /images/clasification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/clasification.png -------------------------------------------------------------------------------- /images/clasification2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/clasification2.png -------------------------------------------------------------------------------- /images/clasiregre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/clasiregre.png -------------------------------------------------------------------------------- /images/cluster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/cluster.png -------------------------------------------------------------------------------- /images/dataframe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/dataframe.jpg -------------------------------------------------------------------------------- /images/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/diagram.png -------------------------------------------------------------------------------- /images/elif.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/elif.png -------------------------------------------------------------------------------- /images/elseIfDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/elseIfDiagram.png -------------------------------------------------------------------------------- /images/flujo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/flujo1.png -------------------------------------------------------------------------------- /images/flujo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/flujo2.png -------------------------------------------------------------------------------- /images/flujo3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/flujo3.png -------------------------------------------------------------------------------- /images/flujo4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/flujo4.png -------------------------------------------------------------------------------- /images/flujo5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/flujo5.png -------------------------------------------------------------------------------- /images/function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/function.png -------------------------------------------------------------------------------- /images/instalation1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation1.png -------------------------------------------------------------------------------- /images/instalation2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation2.png -------------------------------------------------------------------------------- /images/instalation3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation3.png -------------------------------------------------------------------------------- /images/instalation4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation4.png -------------------------------------------------------------------------------- /images/instalation5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation5.png -------------------------------------------------------------------------------- /images/instalation6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation6.png -------------------------------------------------------------------------------- /images/instalation7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/instalation7.png -------------------------------------------------------------------------------- /images/lenna2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/lenna2.png -------------------------------------------------------------------------------- /images/listas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/listas.png -------------------------------------------------------------------------------- /images/logot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/logot.jpg -------------------------------------------------------------------------------- /images/machine_learning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/machine_learning.jpg -------------------------------------------------------------------------------- /images/markdown0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/markdown0.gif -------------------------------------------------------------------------------- /images/markdown2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/markdown2.gif -------------------------------------------------------------------------------- /images/markdown3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/markdown3.gif -------------------------------------------------------------------------------- /images/matrizslice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/matrizslice.png -------------------------------------------------------------------------------- /images/ml_applications.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/ml_applications.png -------------------------------------------------------------------------------- /images/ml_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/ml_map.png -------------------------------------------------------------------------------- /images/numpy_broadcasting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/numpy_broadcasting.png -------------------------------------------------------------------------------- /images/passtest.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/passtest.gif -------------------------------------------------------------------------------- /images/pi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/pi.png -------------------------------------------------------------------------------- /images/process_SL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/process_SL.png -------------------------------------------------------------------------------- /images/procons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/procons.png -------------------------------------------------------------------------------- /images/python_dict.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/python_dict.png -------------------------------------------------------------------------------- /images/reduce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/reduce.png -------------------------------------------------------------------------------- /images/reduce_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/reduce_diagram.png -------------------------------------------------------------------------------- /images/serie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/serie.png -------------------------------------------------------------------------------- /images/series.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/series.jpg -------------------------------------------------------------------------------- /images/series2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/series2.jpg -------------------------------------------------------------------------------- /images/series3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/series3.jpg -------------------------------------------------------------------------------- /images/test1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/test1.gif -------------------------------------------------------------------------------- /images/test2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/test2.gif -------------------------------------------------------------------------------- /images/test3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/test3.gif -------------------------------------------------------------------------------- /images/test4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/test4.gif -------------------------------------------------------------------------------- /images/tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/tokens.png -------------------------------------------------------------------------------- /images/unsuper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/unsuper.jpg -------------------------------------------------------------------------------- /images/validos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/validos.png -------------------------------------------------------------------------------- /images/why.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/images/why.png -------------------------------------------------------------------------------- /styles/FluxBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gersongams/CursoPython/3d060c0cb9fea55e2fd2318563124d5698d88e30/styles/FluxBold.ttf -------------------------------------------------------------------------------- /styles/StyleCursoPython.css: -------------------------------------------------------------------------------- 1 | 2 | Estilo aplicado 3 | 143 | 159 | --------------------------------------------------------------------------------