-# Learn Python 3
+# Aprenda Python 3
[](https://travis-ci.org/jerry-git/learn-python3)
-## Introduction
+## Introducción
-This repository contains a collection of materials for teaching/learning Python 3 (3.5+).
+Este repositorio contiene una colección de materiales para enseñar/aprender Python 3 (3.5+).
-#### Requirements
-* Have Python 3.5 or newer installed. You can check the version by typing `python3 --version` in your command line. You can download the latest Python version from [here](https://www.python.org/downloads/).
-* Have [Jupyter Notebook installed](http://jupyter.readthedocs.io/en/latest/install.html).
+#### Requerimientos
+* Tener Python 3.5 o mayor instalado. Pueden fijarse su versión escribiendo `python3 --version` en su consola. Pueden descargar la última versión de Python [acá](https://www.python.org/downloads/).
+* Tener [Jupyter Notebook instalado](https://www.adictosaltrabajo.com/2018/01/18/primeros-pasos-con-jupyter-notebook/).
-If you can not access Python and/or Jupyter Notebook on your machine, you can still follow the web based materials. However, you should be able to use Jupyter Notebook in order to complete the exercises.
+Si no tienen acceso a Python y/o a Jupyter Notebook en sus maquinas, pueden usar instancias web que se detallan en clase. Sin embargo, es recomendado tenerlo instalado.
-#### Usage
+#### Uso
-1. Clone or download this repository.
-2. Run `jupyter notebook` command in your command line in the repository directory.
-3. Jupyter Notebook session will open in the browser and you can start navigating through the materials.
+1. Clonar o descargar este repositorio.
+2. Hacer el comando `jupyter notebook` en el directorio de este repositorio desde el terminal.
+3. La sesión de Jupyter Notebook se abrirá en el navegador y podrán empezar a navegar los materiales.
-#### Contributing
-See [contributing](https://github.com/jerry-git/learn-python3/blob/master/CONTRIBUTING.md) guide.
-
-## Beginner
+## Novato
1. [Strings](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/strings.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/strings.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/strings_exercise.ipynb)
-1. [Numbers](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/numbers.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/numbers.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/numbers_exercise.ipynb)
-1. [Conditionals](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/conditionals.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/conditionals.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/conditionals_exercise.ipynb)
-1. [Lists](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/lists.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/lists.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/lists_exercise.ipynb)
-1. [Dictionaries](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/dictionaries.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/dictionaries.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/dictionaries_exercise.ipynb)
-1. [For loops](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/for_loops.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/for_loops.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/for_loops_exercise.ipynb)
-1. [Functions](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/functions.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/functions.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/functions_exercise.ipynb)
-1. [Testing with pytest - part 1](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/testing1.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/testing1.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/testing1_exercise.ipynb)
+1. [Numeros](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/numbers.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/numbers.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/numbers_exercise.ipynb)
+1. [Condicionales](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/conditionals.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/conditionals.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/conditionals_exercise.ipynb)
+1. [Listas](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/lists.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/lists.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/lists_exercise.ipynb)
+1. [Diccionarios](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/dictionaries.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/dictionaries.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/dictionaries_exercise.ipynb)
+1. [Bucles for](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/for_loops.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/for_loops.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/for_loops_exercise.ipynb)
+1. [Funciones](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/functions.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/functions.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/functions_exercise.ipynb)
1. Recap exercise 1 [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/recap1_exercise.ipynb)
-1. [File I\O](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/file_io.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/file_io.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/file_io_exercise.ipynb)
-1. [Classes](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/classes.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/classes.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/classes_exercise.ipynb)
-1. [Exceptions](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/exceptions.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/exceptions.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/exceptions_exercise.ipynb)
-1. [Modules and packages](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/modules_and_packages.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/modules_and_packages.ipynb)
-1. [Debugging](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/debugging.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/debugging.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/debugging_exercise.ipynb)
-1. [Goodies of the Standard Library - part 1](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/std_lib.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/std_lib.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/std_lib1_exercise.ipynb)
-1. [Testing with pytest - part 2](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/testing2.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/testing2.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/testing2_exercise.ipynb)
-1. [Virtual environment](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/venv.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/venv.ipynb)
+1. [Archivos I\O](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/file_io.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/file_io.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/file_io_exercise.ipynb)
+1. [Clases](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/classes.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/classes.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/classes_exercise.ipynb)
+1. [Excepciones](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/exceptions.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/exceptions.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/exceptions_exercise.ipynb)
+1. [Módulos y paquetes](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/modules_and_packages.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/modules_and_packages.ipynb)
+1. [Debuggear](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/debugging.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/debugging.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/debugging_exercise.ipynb)
+1. [Cosas de la Librería Estandar - part 1](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/std_lib.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/std_lib.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/std_lib1_exercise.ipynb)
1. [Project structure](https://jerry-git.github.io/learn-python3/notebooks/beginner/html/project_structure.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/notebooks/project_structure.ipynb)
1. Recap exercise 2 [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/beginner/exercises/recap2_exercise.ipynb)
-
-## Intermediate
-
-#### Idiomatic Python
-Python is a powerful language which contains many features not presented in most other programming languages. Idiomatic section will cover some of these Pythonic features in detail. These materials are especially useful for people with background in other programming languages.
-
-1. [Idiomatic loops](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/idiomatic_loops.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/idiomatic_loops.ipynb)
-1. [Idiomatic dictionaries](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/idiomatic_dicts.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/idiomatic_dicts.ipynb)
-1. [Idiomatic Python - miscellaneous part 1](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/idiomatic_misc1.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/idiomatic_misc1.ipynb)
-1. [Idiomatic Python - miscellaneous part 2](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/idiomatic_misc2.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/idiomatic_misc2.ipynb)
-1. Idiomatic Python exercise [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/exercises/idiomatic_python_exercise.ipynb)
-
-#### Step up your `pytest` game
-1. [Efficient use of fixtures](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/pytest_fixtures.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/pytest_fixtures.ipynb)
-1. Other tips and tricks
-
-#### Best practices
-A list of best development practices for Python projects. Most of the practices listed here are also applicable for other languages, however the presented tooling focuses mainly on Python.
-1. [Best practices](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/best_practices.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/best_practices.ipynb)
-
-#### General topics
-1. [Goodies of the Standard Library - part 2](https://jerry-git.github.io/learn-python3/notebooks/intermediate/html/std_lib2.html) [[notebook]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/notebooks/std_lib2.ipynb) [[exercise]](http://nbviewer.jupyter.org/github/jerry-git/learn-python3/blob/master/notebooks/intermediate/exercises/std_lib2_exercise.ipynb)
-
-#### Backlog
-* Sets
-* Generators
-* Decorators
-* Context managers
-* Playing with attributes
-* *, *args, **kwargs
-* Command line arguments with click
-* OOP - inheritance
-* OOP - Abstract Base Classes
-* OOP - attrs
-* Testing with mocks
-* Structuring your tests
-
-
-## Use cases
-
-#### Playing with the web
-* requests
-* testing requests with responses
-* beautifulsoup4
-* selenium
-
-#### Communicating with databases
-* SQLAlchemy
-
-#### Working with documents
-* excel
- * openpyxl
-* pdf
- * pdfrw / PyPDF2
-
-
-## Credits
+## Creditos
* Logo: Abdur-Rahmaan Janhangeer, [@Abdur-rahmaanJ](https://github.com/Abdur-rahmaanJ)
+* Código original: Jerry Pussinen, [@jerry-git](https://github.com/jerry-git)
diff --git a/notebooks/beginner/data/archivo_simple.txt b/notebooks/beginner/data/archivo_simple.txt
new file mode 100644
index 0000000..7b8d6bd
--- /dev/null
+++ b/notebooks/beginner/data/archivo_simple.txt
@@ -0,0 +1,4 @@
+Primer linea
+Segunda linea
+Tercera
+Y la historia sigue!
\ No newline at end of file
diff --git a/notebooks/beginner/data/archivo_simple_con_lineas_vacias.txt b/notebooks/beginner/data/archivo_simple_con_lineas_vacias.txt
new file mode 100644
index 0000000..3613fd4
--- /dev/null
+++ b/notebooks/beginner/data/archivo_simple_con_lineas_vacias.txt
@@ -0,0 +1,6 @@
+El Titulo De La Historia
+
+Primer parrafo con algunas
+palabras sin sentido.
+
+Despues seguimos en el segundo parrafo y asi.
\ No newline at end of file
diff --git a/notebooks/beginner/data/empty_file.txt b/notebooks/beginner/data/archivo_vacio.txt
similarity index 100%
rename from notebooks/beginner/data/empty_file.txt
rename to notebooks/beginner/data/archivo_vacio.txt
diff --git a/notebooks/beginner/data/random_data.txt b/notebooks/beginner/data/data_aleatoria.txt
similarity index 100%
rename from notebooks/beginner/data/random_data.txt
rename to notebooks/beginner/data/data_aleatoria.txt
diff --git a/notebooks/beginner/data/numbers.txt b/notebooks/beginner/data/numeros.txt
similarity index 100%
rename from notebooks/beginner/data/numbers.txt
rename to notebooks/beginner/data/numeros.txt
diff --git a/notebooks/beginner/data/simple_file.txt b/notebooks/beginner/data/simple_file.txt
deleted file mode 100644
index 15d4ea2..0000000
--- a/notebooks/beginner/data/simple_file.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-First line
-Second line
-Third
-And so the story goes!
\ No newline at end of file
diff --git a/notebooks/beginner/data/simple_file_with_empty_lines.txt b/notebooks/beginner/data/simple_file_with_empty_lines.txt
deleted file mode 100644
index 9c3bb9f..0000000
--- a/notebooks/beginner/data/simple_file_with_empty_lines.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-The Title of the Story
-
-First paragraph with some
-nonsense words.
-
-Then we move to second paragraph and so on.
\ No newline at end of file
diff --git a/notebooks/beginner/exercises/classes_exercise.ipynb b/notebooks/beginner/exercises/classes_exercise.ipynb
index 5e60c49..993d3e3 100644
--- a/notebooks/beginner/exercises/classes_exercise.ipynb
+++ b/notebooks/beginner/exercises/classes_exercise.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Fill the missing pieces of the `Calculator` class\n",
- "Fill `____` pieces of the `Calculator` implemention in order to pass the assertions."
+ "# 1. Llenen las partes faltantes de la clase `Calculadora`\n",
+ "Llenen los pedazos `____` de la implementacion de `Calculadora` para pasar las pruebas."
]
},
{
@@ -14,15 +14,15 @@
"metadata": {},
"outputs": [],
"source": [
- "class Calculator:\n",
+ "class Calculadora:\n",
" def __init__(self, var1, ____):\n",
" self.____ = var1\n",
" self.____ = _____\n",
" \n",
- " def calculate_power(self):\n",
+ " def calcular_potencia(self):\n",
" return self.____ ** ____.____\n",
" \n",
- " def calculate_sum(____, var3):\n",
+ " def calcular_suma(____, var3):\n",
" return ____.____ + ____.____ + var3"
]
},
@@ -34,17 +34,17 @@
},
"outputs": [],
"source": [
- "calc = Calculator(2, 3)\n",
- "assert calc.calculate_power() == 8\n",
- "assert calc.calculate_sum(4) == 9"
+ "calc = Calculadora(2, 3)\n",
+ "assert calc.calcular_potencia() == 8\n",
+ "assert calc.calcular_suma(4) == 9"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Finalize `StringManipulator` class\n",
- "Fill `____` pieces and create implementation for `stripped_title()`."
+ "# 2. Finalicen la clase `ManipuladorString`\n",
+ "Llenen los pedazos `____` y creen una implementacion para `titulo_desnudo()`."
]
},
{
@@ -53,22 +53,22 @@
"metadata": {},
"outputs": [],
"source": [
- "class StringManipulator:\n",
+ "class ManipuladorString:\n",
" \"\"\"____\"\"\"\n",
" \n",
- " category = ____\n",
+ " categoria = ____\n",
" \n",
" def __init__(self, original):\n",
" self.string = ____\n",
" \n",
- " def reverse_words(self):\n",
- " words = self.string.____\n",
+ " def invertir_palabras(self):\n",
+ " palabras = self.string.____\n",
" self.string = ' '.join(reversed(____))\n",
" \n",
- " def make_title(self):\n",
- " # Create implementation for this\n",
+ " def hacer_titulo(self):\n",
+ " # Crear una implementacion para esto\n",
" \n",
- " def get_manipulated(____):\n",
+ " def obtener_manipulado(____):\n",
" return self._____"
]
},
@@ -80,29 +80,29 @@
},
"outputs": [],
"source": [
- "assert StringManipulator.__doc__ == 'Docstring of StringManipulator'\n",
- "assert StringManipulator.category == 'Manipulator'\n",
+ "assert ManipuladorString.__doc__ == 'Docstring de ManipuladorString'\n",
+ "assert ManipuladorString.categoria == 'Manipulador'\n",
"\n",
- "str_manip = StringManipulator('cOOL pyThON')\n",
+ "manip_str = ManipuladorString('geNIaL pYtHOn')\n",
"\n",
- "str_manip.reverse_words()\n",
- "assert str_manip.get_manipulated() == 'pyThON cOOL'\n",
+ "manip_str.invertir_palabras()\n",
+ "assert manip_str.obtener_manipulado() == 'pYtHOn geNIaL'\n",
"\n",
- "str_manip.make_title()\n",
- "assert str_manip.get_manipulated() == 'Python Cool'"
+ "manip_str.hacer_titulo()\n",
+ "assert manip_str.obtener_manipulado() == 'Python Genial'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 3. Create `Dog` class\n",
- "Create `Dog` class which has the following specification:\n",
- "* Dogs consume their energy by barking and gain energy by sleeping\n",
- "* A fresh `Dog` instance has 10 units of energy\n",
- "* `Dog` has a method `sleep` which gives 2 units of energy\n",
- "* `Dog` has a method `bark` which consumes 1 unit of energy\n",
- "* `Dog` has a method `get_energy` which returns the amount of energy left "
+ "# 3. Crear la clase `Perro`\n",
+ "Crear la clase `Perro` que tiene las siguientes caracteristicas:\n",
+ "* Perros consumen su energia ladrando y la ganan durmiendo\n",
+ "* Una instancia `Perro` fresca tiene 10 unidades de energia\n",
+ "* `Perro` tiene un metodo `dormir` que le da 2 unidades de energia\n",
+ "* `Perro` tiene un metodo `ladrar` que consume 1 unidad de energia\n",
+ "* `Perro` tiene un metodo `obtener_energia` que devuelve la cantidad de energia sobrante "
]
},
{
@@ -111,8 +111,8 @@
"metadata": {},
"outputs": [],
"source": [
- "class Dog:\n",
- " # Your implementation here"
+ "class Perro:\n",
+ " # Tu implementacion aca"
]
},
{
@@ -123,19 +123,19 @@
},
"outputs": [],
"source": [
- "doge = Dog()\n",
- "assert doge.get_energy() == 10\n",
+ "perrete = Perro()\n",
+ "assert perrete.obtener_energia() == 10\n",
"\n",
- "doge.bark()\n",
- "doge.bark()\n",
- "doge.bark()\n",
- "assert doge.get_energy() == 7\n",
+ "perrete.ladrar()\n",
+ "perrete.ladrar()\n",
+ "perrete.ladrar()\n",
+ "assert perrete.obtener_energia() == 7\n",
"\n",
- "doge.sleep()\n",
- "assert doge.get_energy() == 9\n",
+ "perrete.dormir()\n",
+ "assert perrete.obtener_energia() == 9\n",
"\n",
- "another_doge = Dog()\n",
- "assert another_doge.get_energy() == 10"
+ "otro_perrete = Perro()\n",
+ "assert otro_perrete.obtener_energia() == 10"
]
}
],
diff --git a/notebooks/beginner/exercises/conditionals_exercise.ipynb b/notebooks/beginner/exercises/conditionals_exercise.ipynb
index e0e045c..f814113 100644
--- a/notebooks/beginner/exercises/conditionals_exercise.ipynb
+++ b/notebooks/beginner/exercises/conditionals_exercise.ipynb
@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"# 1. `if-elif-else`\n",
- "Fill missing pieces (`____`) of the following code such that prints make sense."
+ "Llenar los espacios faltantes (`____`) del siguiente codigo de manera que tenga sentido."
]
},
{
@@ -16,7 +16,7 @@
},
"outputs": [],
"source": [
- "name = 'John Doe'"
+ "nombre = 'John Doe'"
]
},
{
@@ -26,20 +26,20 @@
"outputs": [],
"source": [
"if ____:\n",
- " print('Name \"{}\" is more than 20 chars long'.format(name))\n",
- " length_description = 'long'\n",
+ " print('Nombre \"{}\" tiene mas de 20 caracteres de largo'.format(nombre))\n",
+ " descripcion_largo = 'largo'\n",
"elif ____:\n",
- " print('Name \"{}\" is more than 15 chars long'.format(name))\n",
- " length_description = 'semi long'\n",
+ " print('Nombre \"{}\" tiene mas de 15 caracteres de largo'.format(nombre))\n",
+ " descripcion_largo = 'semi largo'\n",
"elif ____:\n",
- " print('Name \"{}\" is more than 10 chars long'.format(name))\n",
- " length_description = 'semi long'\n",
+ " print('Nombre \"{}\" tiene mas de 10 caracteres de largo'.format(nombre))\n",
+ " descripcion_largo = 'semi largo'\n",
"elif ____:\n",
- " print('Name \"{}\" is 8, 9 or 10 chars long'.format(name))\n",
- " length_description = 'semi short'\n",
+ " print('Nombre \"{}\" tiene 8, 9 o 10 caracteres de largo'.format(nombre))\n",
+ " descripcion_largo = 'semi corto'\n",
"else:\n",
- " print('Name \"{}\" is a short name'.format(name))\n",
- " length_description = 'short'"
+ " print('Nombre \"{}\" es un nombre corto'.format(nombre))\n",
+ " descripcion_largo = 'corto'"
]
},
{
@@ -50,7 +50,7 @@
},
"outputs": [],
"source": [
- "assert length_description == 'semi short'"
+ "assert descripcion_largo == 'semi corto'"
]
}
],
diff --git a/notebooks/beginner/exercises/dictionaries_exercise.ipynb b/notebooks/beginner/exercises/dictionaries_exercise.ipynb
index 06b3b07..5c6c2a1 100644
--- a/notebooks/beginner/exercises/dictionaries_exercise.ipynb
+++ b/notebooks/beginner/exercises/dictionaries_exercise.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Populating a dictionary\n",
- "Create a dictionary by using all the given variables."
+ "# 1. Popular diccionarios\n",
+ "Crear un diccionario usando todas las variables dadas."
]
},
{
@@ -16,11 +16,11 @@
},
"outputs": [],
"source": [
- "first_name = 'John'\n",
- "last_name = 'Doe'\n",
- "favorite_hobby = 'Python'\n",
- "sports_hobby = 'gym'\n",
- "age = 82"
+ "nombre = 'John'\n",
+ "apellido = 'Doe'\n",
+ "hobby_favorito = 'Python'\n",
+ "hobby_deporte = 'gym'\n",
+ "edad = 82"
]
},
{
@@ -29,8 +29,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation\n",
- "my_dict = "
+ "# Tu implementacion\n",
+ "mi_dicc = "
]
},
{
@@ -41,9 +41,9 @@
},
"outputs": [],
"source": [
- "assert my_dict == {\n",
- " 'name': 'John Doe',\n",
- " 'age': 82,\n",
+ "assert mi_dicc == {\n",
+ " 'nombre': 'John Doe',\n",
+ " 'edad': 82,\n",
" 'hobbies': ['Python', 'gym']\n",
" }"
]
@@ -52,8 +52,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Accessing and merging dictionaries\n",
- "Combine `dict1`, `dict2`, and `dict3` into `my_dict`. In addition, get the value of `special_key` from `my_dict` into a `special_value` variable. Note that original dictionaries should stay untouched and `special_key` should be removed from `my_dict`."
+ "# 2. Accediendo y combinando diccionarios\n",
+ "Combinen `dicc1`, `dicc2`, y `dicc3` en `mi_dicc`. Además, pongan el valor de `llave_especial` de `mi_dicc` en la variable `valor_especial`. Noten que los diccionarios originales no deben ser modificados y `llave_especial` debería ser eliminada de `mi_dicc`."
]
},
{
@@ -64,10 +64,10 @@
},
"outputs": [],
"source": [
- "dict1 = dict(key1='This is not that hard', key2='Python is still cool')\n",
- "dict2 = {'key1': 123, 'special_key': 'secret'}\n",
- "# This is also a away to initialize a dict (list of tuples) \n",
- "dict3 = dict([('key2', 456), ('keyX', 'X')])"
+ "dicc1 = dict(llave1='Esto no es tan dificil', llave2='Python sigue estando bueno')\n",
+ "dicc2 = {'llave1': 123, 'llave_especial': 'secreto'}\n",
+ "# Esta es otra forma de hacer un diccionario (lista de tuplas) \n",
+ "dicc3 = dict([('llave2', 456), ('llaveX', 'X')])"
]
},
{
@@ -76,9 +76,9 @@
"metadata": {},
"outputs": [],
"source": [
- "# 'Your impelementation'\n",
- "my_dict = \n",
- "special_value = "
+ "# 'Tu implementacion'\n",
+ "mi_dicc = \n",
+ "valor_especial = "
]
},
{
@@ -89,16 +89,16 @@
},
"outputs": [],
"source": [
- "assert my_dict == {'key1': 123, 'key2': 456, 'keyX': 'X'}\n",
- "assert special_value == 'secret'\n",
+ "assert mi_dicc == {'llave1': 123, 'llave2': 456, 'llaveX': 'X'}\n",
+ "assert valor_especial == 'secreto'\n",
"\n",
- "# Let's check that the originals are untouched\n",
- "assert dict1 == {\n",
- " 'key1': 'This is not that hard',\n",
- " 'key2': 'Python is still cool'\n",
+ "# Vamos a verificar que las originales no fueron modificadas...\n",
+ "assert dicc1 == {\n",
+ " 'llave1': 'Esto no es tan dificil',\n",
+ " 'llave2': 'Python sigue estando bueno'\n",
" }\n",
- "assert dict2 == {'key1': 123, 'special_key': 'secret'}\n",
- "assert dict3 == {'key2': 456, 'keyX': 'X'}"
+ "assert dicc2 == {'llave1': 123, 'llave_especial': 'secreto'}\n",
+ "assert dicc3 == {'llave2': 456, 'llaveX': 'X'}"
]
}
],
diff --git a/notebooks/beginner/exercises/file_io_exercise.ipynb b/notebooks/beginner/exercises/file_io_exercise.ipynb
index 40ea966..872c08c 100644
--- a/notebooks/beginner/exercises/file_io_exercise.ipynb
+++ b/notebooks/beginner/exercises/file_io_exercise.ipynb
@@ -8,21 +8,21 @@
},
"outputs": [],
"source": [
- "# EXECUTE THIS ONE FIRST!\n",
+ "# EJECUTEN ESTO PRIMERO!\n",
"\n",
"import os\n",
"\n",
- "# Constants for the exercises:\n",
- "WORKING_DIR = os.getcwd()\n",
- "DATA_DIR = os.path.join(os.path.dirname(WORKING_DIR), 'data')"
+ "# Constantes para los ejercicios:\n",
+ "DIR_TRABAJO = os.getcwd()\n",
+ "DIR_DATA = os.path.join(os.path.dirname(DIR_TRABAJO), 'data')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Sum numbers listed in a file\n",
- "Fill ____ pieces of the code below. `sum_numbers_in_file` function takes a input file path as argument, reads the numbers listed in the input file and returns the sum of those numbers. You can assume that each line contains exactly one numeric value."
+ "# 1. Sumen numeros listados en un archivo\n",
+ "Llenen los pedazos ____ faltantes de codigo abajo. La funcion `sumar_numeros_en_archivo` toma una ruta de archivo como argumento, lee los numeros listados en el archivo de entrada y devuelve la suma de esos numeros. Pueden asumir que cada lineaa contiene solo un numero."
]
},
{
@@ -31,11 +31,11 @@
"metadata": {},
"outputs": [],
"source": [
- "def sum_numbers_in_file(input_file):\n",
- " sum_ = 0 # A common way to use variable names that collide with built-in/keyword words is to add underscore\n",
- " with ____(input_file, ____) as ____:\n",
- " for line in ____:\n",
- " ____ = line.strip() # Remove potential white space \n",
+ "def sumar_numeros_en_archivo(archivo_entrada):\n",
+ " sum_ = 0 # Una forma comun de usar nombres de variables que hacen conflicto con las palabras claves por defecto es aniadiendo un guion bajo\n",
+ " with ____(archivo_entrada, ____) as ____:\n",
+ " for linea in ____:\n",
+ " ____ = linea.strip() # Borramos espacios blancos por las dudas \n",
" ____ += float(____)\n",
" return ____"
]
@@ -48,16 +48,16 @@
},
"outputs": [],
"source": [
- "in_file = os.path.join(DATA_DIR, 'numbers.txt')\n",
- "assert sum_numbers_in_file(in_file) == 189.5"
+ "archivo_entr = os.path.join(DIR_DATA, 'numeros.txt')\n",
+ "assert sumar_numeros_en_archivo(archivo_entr) == 189.5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Reading first word from each line of a file\n",
- "Implement `find_first_words` function which takes an input file path as argument. The function should find the first word of each line in the file and return these words as a list. If a line is empty, the returned list should contain an empty string for that line."
+ "# 2. Leer primera palabra de cada linea de un archivo.\n",
+ "Implementen la funcion `encontrar_primer_palabra` que toma una ruta de un archivo como argumento. La funcion debería encontrar la primera palabra de cada linea en el archivo y devolverlas como una lista. Si la linea esta vacia, la lista retornada deberia contener un string vacio por esa linea."
]
},
{
@@ -66,7 +66,7 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation here"
+ "# Tu implementacion aca"
]
},
{
@@ -77,14 +77,14 @@
},
"outputs": [],
"source": [
- "in_file1 = os.path.join(DATA_DIR, 'simple_file.txt')\n",
- "in_file2 = os.path.join(DATA_DIR, 'simple_file_with_empty_lines.txt')\n",
+ "archivo_entr1 = os.path.join(DIR_DATA, 'archivo_simple.txt')\n",
+ "archivo_entr2 = os.path.join(DIR_DATA, 'archivo_simple_con_lineas_vacias.txt')\n",
"\n",
- "expected_file_1 = ['First', 'Second', 'Third', 'And']\n",
- "assert find_first_words(in_file1) == expected_file_1\n",
+ "archivo_esperado_1 = ['Primer', 'Segunda', 'Tercera', 'Y']\n",
+ "assert encontrar_primer_palabra(archivo_entr1) == archivo_esperado_1\n",
"\n",
- "expected_file_2 = ['The', '', 'First', 'nonsense', '', 'Then']\n",
- "assert find_first_words(in_file2) == expected_file_2"
+ "archivo_esperado_2 = ['El', '', 'Primer', 'palabras', '', 'Despues']\n",
+ "assert encontrar_primer_palabra(archivo_entr2) == archivo_esperado_2"
]
}
],
diff --git a/notebooks/beginner/exercises/for_loops_exercise.ipynb b/notebooks/beginner/exercises/for_loops_exercise.ipynb
index eae36c6..10bab1b 100644
--- a/notebooks/beginner/exercises/for_loops_exercise.ipynb
+++ b/notebooks/beginner/exercises/for_loops_exercise.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Fill the missing pieces\n",
- "Fill the `____` parts in the code below."
+ "# 1. Llenen los espacios faltantes\n",
+ "Llenen los espacios `____` del codigo de abajo."
]
},
{
@@ -14,8 +14,8 @@
"metadata": {},
"outputs": [],
"source": [
- "words = ['PYTHON', 'JOHN', 'chEEse', 'hAm', 'DOE', '123']\n",
- "upper_case_words = []\n",
+ "words = ['PYTHON', 'JOHN', 'quEEso', 'jAMon', 'DOE', '123']\n",
+ "palabras_mayusculas = []\n",
"\n",
"for ____ in words:\n",
" if ____.isupper():\n",
@@ -30,15 +30,15 @@
},
"outputs": [],
"source": [
- "assert upper_case_words == ['PYTHON', 'JOHN', 'DOE']"
+ "assert palabras_mayusculas == ['PYTHON', 'JOHN', 'DOE']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Calculate the sum of dict values\n",
- "Calculate the sum of the values in `magic_dict` by taking only into account numeric values (hint: see [isinstance](https://docs.python.org/3/library/functions.html#isinstance)). "
+ "# 2. Calcular la suma de los valores del diccionario\n",
+ "Calcular la suma de los valores en `dicc_magico` tomando en cuenta solo los valores numericos (pista: vean [isinstance](https://docs.python.org/3/library/functions.html#isinstance)). "
]
},
{
@@ -49,7 +49,7 @@
},
"outputs": [],
"source": [
- "magic_dict = dict(val1=44, val2='secret value', val3=55.0, val4=1)"
+ "dicc_magico = dict(val1=44, val2='valor secreto', val3=55.0, val4=1)"
]
},
{
@@ -58,8 +58,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation\n",
- "sum_of_values = "
+ "# Tu implementation\n",
+ "suma_de_valores = "
]
},
{
@@ -70,19 +70,19 @@
},
"outputs": [],
"source": [
- "assert sum_of_values == 100"
+ "assert suma_de_valores == 100"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 3. Create a list of strings based on a list of numbers\n",
- "The rules:\n",
- "* If the number is a multiple of five and odd, the string should be `'five odd'`\n",
- "* If the number is a multiple of five and even, the string should be `'five even'`\n",
- "* If the number is odd, the string is `'odd'`\n",
- "* If the number is even, the string is `'even'`"
+ "# 3. Creen una lista de strings basados en una lista de numeros\n",
+ "Las reglas:\n",
+ "* Si el numero es un multiplo de cinco y es impar, el string debería ser `'cinco impar'`\n",
+ "* Si el numero es un multiplo de cinco y es par, el string debería ser `'cinco par'`\n",
+ "* Si el numero es impar, el string debería ser `'impar'`\n",
+ "* Si el numero es par, el string debería ser `'par'`"
]
},
{
@@ -102,8 +102,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation\n",
- "my_list = "
+ "# Tu implementacion\n",
+ "mi_lista = "
]
},
{
@@ -114,7 +114,7 @@
},
"outputs": [],
"source": [
- "assert my_list == ['odd', 'odd', 'even', 'even', 'odd', 'five even', 'five even', 'five odd']"
+ "assert mi_lista == ['impar', 'impar', 'par', 'par', 'impar', 'cinco par', 'cinco par', 'cinco impar']"
]
}
],
diff --git a/notebooks/beginner/exercises/functions_exercise.ipynb b/notebooks/beginner/exercises/functions_exercise.ipynb
index 64f891e..32e3a4a 100644
--- a/notebooks/beginner/exercises/functions_exercise.ipynb
+++ b/notebooks/beginner/exercises/functions_exercise.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Fill the missing pieces of the `count_even_numbers` function\n",
- "Fill `____` pieces of the `count_even_numbers` implemention in order to pass the assertions. You can assume that `numbers` argument is a list of integers."
+ "# 1. Llenen las piezas faltantes de la funcion `contar_numeros_pares`\n",
+ "Llenen los espacios `____` de la implentacion de `contar_numeros_pares` para pasar las pruebas. Pueden asumir que el argumento `numeros` es una lista de ints."
]
},
{
@@ -14,11 +14,11 @@
"metadata": {},
"outputs": [],
"source": [
- "____ count_even_numbers(numbers):\n",
- " count = 0\n",
+ "____ contar_numeros_pares(numeros):\n",
+ " cuenta = 0\n",
" for num in ____:\n",
" if ____ % 2 == ____:\n",
- " count += ____\n",
+ " cuenta += ____\n",
" _____ _____"
]
},
@@ -30,17 +30,17 @@
},
"outputs": [],
"source": [
- "assert count_even_numbers([1, 2, 3, 4, 5, 6]) == 3\n",
- "assert count_even_numbers([1, 3, 5, 7]) == 0\n",
- "assert count_even_numbers([-2, 2, -10, 8]) == 4"
+ "assert contar_numeros_pares([1, 2, 3, 4, 5, 6]) == 3\n",
+ "assert contar_numeros_pares([1, 3, 5, 7]) == 0\n",
+ "assert contar_numeros_pares([-2, 2, -10, 8]) == 4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Searching for wanted people\n",
- "Implement `find_wanted_people` function which takes a list of names (strings) as argument. The function should return a list of names which are present both in `WANTED_PEOPLE` and in the name list given as argument to the function."
+ "# 2. Capturando personas buscadas\n",
+ "Implementen la funcion `capturas_personas_buscadas` que tome una lista de nombres (strings) como argumento. La funcion debería devolver una lista de nombres que esten presentes tanto en `PERSONAS_BUSCADAS` y en la lista de nombres que fue dada como argumento a la funcion."
]
},
{
@@ -51,7 +51,7 @@
},
"outputs": [],
"source": [
- "WANTED_PEOPLE = ['John Doe', 'Clint Eastwood', 'Chuck Norris']"
+ "PERSONAS_BUSCADAS = ['John Doe', 'Clint Eastwood', 'Chuck Norris']"
]
},
{
@@ -60,7 +60,7 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation here"
+ "# Tu implementacion aca"
]
},
{
@@ -71,23 +71,23 @@
},
"outputs": [],
"source": [
- "people_to_check1 = ['Donald Duck', 'Clint Eastwood', 'John Doe', 'Barack Obama']\n",
- "wanted1 = find_wanted_people(people_to_check1)\n",
- "assert len(wanted1) == 2\n",
- "assert 'John Doe' in wanted1\n",
- "assert 'Clint Eastwood'in wanted1\n",
+ "personas_a_verificar = ['Donald Duck', 'Clint Eastwood', 'John Doe', 'Barack Obama']\n",
+ "buscadas1 = capturas_personas_buscadas(personas_a_verificar)\n",
+ "assert len(buscadas1) == 2\n",
+ "assert 'John Doe' in buscadas1\n",
+ "assert 'Clint Eastwood'in buscadas1\n",
"\n",
- "people_to_check2 = ['Donald Duck', 'Mickey Mouse', 'Zorro', 'Superman', 'Robin Hood']\n",
- "wanted2 = find_wanted_people(people_to_check2)\n",
- "assert wanted2 == []"
+ "personas_a_verificar2 = ['Donald Duck', 'Mickey Mouse', 'Zorro', 'Superman', 'Robin Hood']\n",
+ "buscadas2 = capturas_personas_buscadas(personas_a_verificar2)\n",
+ "assert buscadas2 == []"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 3. Counting average length of words in a sentence\n",
- "Create a function `average_length_of_words` which takes a string as an argument and returns the average length of the words in the string. You can assume that there is a single space between each word and that the input does not have punctuation. The result should be rounded to one decimal place (hint: see [`round`](https://docs.python.org/3/library/functions.html#round))."
+ "# 3. Encontrar la longitud promedio de las palabras en una oracion\n",
+ "Crear una funcion `longitud_promedio_de_palabras` que tome un string como argumento y devuelva la longitud promedio de las palabras en el string. Pueden asumir que hay un solo espacio entre cada palabra y que la entrada no tiene ninguna puntuacion. El resultado debería ser redondeado a un decimal (pista: vean [`round`](https://docs.python.org/3/library/functions.html#round))."
]
},
{
@@ -96,7 +96,7 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation here"
+ "# Tu implementacion aca"
]
},
{
@@ -107,10 +107,10 @@
},
"outputs": [],
"source": [
- "assert average_length_of_words('only four lett erwo rdss') == 4\n",
- "assert average_length_of_words('one two three') == 3.7\n",
- "assert average_length_of_words('one two three four') == 3.8\n",
- "assert average_length_of_words('') == 0"
+ "assert longitud_promedio_de_palabras('solo cuat ropa labr asss') == 4\n",
+ "assert longitud_promedio_de_palabras('uno dos tres') == 3.3\n",
+ "assert longitud_promedio_de_palabras('uno dos tres cuatro cinco') == 4.2\n",
+ "assert longitud_promedio_de_palabras('') == 0"
]
}
],
diff --git a/notebooks/beginner/exercises/lists_exercise.ipynb b/notebooks/beginner/exercises/lists_exercise.ipynb
index 9c7645b..4cdab9a 100644
--- a/notebooks/beginner/exercises/lists_exercise.ipynb
+++ b/notebooks/beginner/exercises/lists_exercise.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Fill the missing pieces\n",
- "Fill the `____` parts of the code below."
+ "# 1. Llenen los espacios\n",
+ "Llenen las partes `____` del codigo de abajo."
]
},
{
@@ -14,19 +14,19 @@
"metadata": {},
"outputs": [],
"source": [
- "# Let's create an empty list\n",
- "my_list = ____\n",
+ "# Vamos a crear una lista vacia\n",
+ "mi_lista = ____\n",
"\n",
- "# Let's add some values\n",
- "my_list.____('Python')\n",
- "my_list.____('is ok')\n",
- "my_list.____('sometimes')\n",
+ "# Vamos a añadir algunos valores\n",
+ "mi_lista.____('Python')\n",
+ "mi_lista.____('esta bueno')\n",
+ "mi_lista.____('a veces')\n",
"\n",
- "# Let's remove 'sometimes'\n",
- "my_list.____('sometimes')\n",
+ "# Vamos a sacar 'a veces'\n",
+ "mi_lista.____('a veces')\n",
"\n",
- "# Let's change the second item\n",
- "my_list[____] = 'is neat'"
+ "# Cambiemos el segundo item\n",
+ "mi_lista[____] = 'es interesante'"
]
},
{
@@ -37,15 +37,15 @@
},
"outputs": [],
"source": [
- "# Let's verify that it's correct\n",
- "assert my_list == ['Python', 'is neat']"
+ "# Verificamos que lo hayamos hecho bien\n",
+ "assert mi_lista == ['Python', 'es interesante']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Create a new list without modifiying the original one\n"
+ "# 2. Creen una nueva lista sin modificar la original\n"
]
},
{
@@ -56,7 +56,7 @@
},
"outputs": [],
"source": [
- "original = ['I', 'am', 'learning', 'hacking', 'in']"
+ "original = ['Estoy', 'aprendiendo', 'a', 'hackear', 'en']"
]
},
{
@@ -65,8 +65,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation here\n",
- "modified = "
+ "# Tu implementacion aca\n",
+ "modificado = "
]
},
{
@@ -77,15 +77,15 @@
},
"outputs": [],
"source": [
- "assert original == ['I', 'am', 'learning', 'hacking', 'in']\n",
- "assert modified == ['I', 'am', 'learning', 'lists', 'in', 'Python']"
+ "assert original == ['Estoy', 'aprendiendo', 'a', 'hackear', 'en']\n",
+ "assert modificado == ['Estoy', 'aprendiendo', 'a', 'hackear', 'en', 'Python']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 3. Create a merged sorted list"
+ "# 3. Creen una lista combinada y ordenada"
]
},
{
@@ -96,9 +96,9 @@
},
"outputs": [],
"source": [
- "list1 = [6, 12, 5]\n",
- "list2 = [6.2, 0, 14, 1]\n",
- "list3 = [0.9]"
+ "lista1 = [6, 12, 5]\n",
+ "lista2 = [6.2, 0, 14, 1]\n",
+ "lista3 = [0.9]"
]
},
{
@@ -107,8 +107,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation here\n",
- "my_list = "
+ "# Tu implementacion aca\n",
+ "mi_lista = "
]
},
{
@@ -120,8 +120,8 @@
},
"outputs": [],
"source": [
- "print(my_list)\n",
- "assert my_list == [14, 12, 6.2, 6, 5, 1, 0.9, 0]"
+ "print(mi_lista)\n",
+ "assert mi_lista == [14, 12, 6.2, 6, 5, 1, 0.9, 0]"
]
}
],
diff --git a/notebooks/beginner/exercises/numbers_exercise.ipynb b/notebooks/beginner/exercises/numbers_exercise.ipynb
index 9b25a95..c98cf8a 100644
--- a/notebooks/beginner/exercises/numbers_exercise.ipynb
+++ b/notebooks/beginner/exercises/numbers_exercise.ipynb
@@ -4,11 +4,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Creating formulas\n",
- "Write the following mathematical formula in Python:\n",
+ "# 1. Creando formulas\n",
+ "Escriban la siguiente formula matematica en Python:\n",
"\n",
"\\begin{align}\n",
- " result = 6a^3 - \\frac{8b^2 }{4c} + 11\n",
+ " resultado = 6a^3 - \\frac{8b^2 }{4c} + 11\n",
"\\end{align}\n"
]
},
@@ -31,8 +31,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your formula here:\n",
- "result = "
+ "# Tu formula aca:\n",
+ "resultado = "
]
},
{
@@ -44,15 +44,15 @@
"outputs": [],
"source": [
"\n",
- "assert result == 50"
+ "assert resultado == 50"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Floating point pitfalls\n",
- "Show that `0.1 + 0.2 == 0.3`"
+ "# 2. Cuidados con los floats\n",
+ "Muestren que `0.1 + 0.2 == 0.3`"
]
},
{
@@ -61,9 +61,9 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your solution here\n",
+ "# Tu solucion aca\n",
"\n",
- "# This won't work:\n",
+ "# Esto no va a funcionar:\n",
"# assert 0.1 + 0.2 == 0.3"
]
}
diff --git a/notebooks/beginner/exercises/strings_exercise.ipynb b/notebooks/beginner/exercises/strings_exercise.ipynb
index 38aee8b..3cd5a96 100644
--- a/notebooks/beginner/exercises/strings_exercise.ipynb
+++ b/notebooks/beginner/exercises/strings_exercise.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 1. Fill missing pieces\n",
- "Fill `____` pieces below to have correct values for `lower_cased`, `stripped` and `stripped_lower_case` variables."
+ "# 1. Llenen los espacios\n",
+ "Llenen los espacios `____` abajo para que tengan los valores correctos para `en_minuscula`, `desnudo` and `desnudo_lower_case` variables."
]
},
{
@@ -14,17 +14,17 @@
"metadata": {},
"outputs": [],
"source": [
- "original = ' Python strings are COOL! '\n",
- "lower_cased = original._____\n",
- "stripped = ____.strip()\n",
- "stripped_lower_cased = original._____._____"
+ "original = ' Los strings de Python son GENIALES! '\n",
+ "en_minuscula = original._____\n",
+ "desnudo = ____.strip()\n",
+ "desnudo_en_minuscula = original._____._____"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Let's verify that the implementation is correct by running the cell below. `assert` will raise `AssertionError` if the statement is not true. "
+ "Vamos a verificar que la implementación es correcta ejecutando las celdas de abajo. `assert` va a lanzar un error `AssertionError` si la declaración no es verdadera. "
]
},
{
@@ -35,17 +35,17 @@
},
"outputs": [],
"source": [
- "assert lower_cased == ' python strings are cool! '\n",
- "assert stripped == 'Python strings are COOL!'\n",
- "assert stripped_lower_cased == 'python strings are cool!'"
+ "assert en_minuscula == ' los strings de python son geniales! '\n",
+ "assert desnudo == 'Los strings de Python son GENIALES!'\n",
+ "assert desnudo_en_minuscula == 'los strings de python son geniales!'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 2. Prettify ugly string\n",
- "Use `str` methods to convert `ugly` to wanted `pretty`."
+ "# 2. Mejoren los strings feos\n",
+ "Usen el metodo `str` para convertir strings `feos` en `lindos`."
]
},
{
@@ -56,7 +56,7 @@
},
"outputs": [],
"source": [
- "ugly = ' tiTle of MY new Book\\n\\n'"
+ "feo = ' tiTuLo de MI nuEvo Libro\\n\\n'"
]
},
{
@@ -65,15 +65,15 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation:\n",
- "pretty = 'TODO'"
+ "# Tu implementacion:\n",
+ "lindo = 'TODO'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Let's make sure that it does what we want. `assert` raises [`AssertionError`](https://docs.python.org/3/library/exceptions.html#AssertionError) if the statement is not `True`."
+ "Vamos a asegurarnos que hace lo que queremos. `assert` levanta el error [`AssertionError`](https://docs.python.org/3/library/exceptions.html#AssertionError) si la declaración no es `True`."
]
},
{
@@ -84,16 +84,16 @@
},
"outputs": [],
"source": [
- "print('pretty: {}'.format(pretty))\n",
- "assert pretty == 'Title Of My New Book'"
+ "print('lindo: {}'.format(lindo))\n",
+ "assert lindo == 'Titulo De Mi Nuevo Libro'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# 3. Format string based on existing variables\n",
- "Create `sentence` by using `verb`, `language`, and `punctuation` and any other strings you may need."
+ "# 3. Formateen el string con las variables existentes\n",
+ "Creen `oracion` usando `verbo`, `lenguaje`, y `puntuacion` y cualquier otro string que necesiten."
]
},
{
@@ -104,9 +104,9 @@
},
"outputs": [],
"source": [
- "verb = 'is'\n",
- "language = 'Python'\n",
- "punctuation = '!'"
+ "verbo = 'es'\n",
+ "lenguaje = 'Python'\n",
+ "puntuacion = '!'"
]
},
{
@@ -115,8 +115,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your implementation:\n",
- "sentence = 'TODO'"
+ "# Tu implementacion:\n",
+ "oracion = 'TODO'"
]
},
{
@@ -127,18 +127,18 @@
},
"outputs": [],
"source": [
- "print('sentence: {}'.format(sentence))\n",
- "assert sentence == 'Learning Python is fun!'"
+ "print('oracion: {}'.format(oracion))\n",
+ "assert oracion == 'Aprender Python es divertido!'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
- "language": "python",
+ "lenguaje": "python",
"name": "python3"
},
- "language_info": {
+ "lenguaje_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
diff --git a/notebooks/beginner/notebooks/classes.ipynb b/notebooks/beginner/notebooks/classes.ipynb
index b39b340..3e733fc 100644
--- a/notebooks/beginner/notebooks/classes.ipynb
+++ b/notebooks/beginner/notebooks/classes.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# [Classes](https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes)"
+ "# [Clases](https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes)"
]
},
{
@@ -13,12 +13,12 @@
"metadata": {},
"outputs": [],
"source": [
- "class MyFirstClass:\n",
- " def __init__(self, name):\n",
- " self.name = name\n",
+ "class MiPrimerClase:\n",
+ " def __init__(self, nombre):\n",
+ " self.nombre = nombre\n",
"\n",
- " def greet(self):\n",
- " print('Hello {}!'.format(self.name))"
+ " def saludar(self):\n",
+ " print('Hola {}!'.format(self.nombre))"
]
},
{
@@ -27,18 +27,18 @@
"metadata": {},
"outputs": [],
"source": [
- "my_instance = MyFirstClass('John Doe')\n",
- "print('my_instance: {}'.format(my_instance))\n",
- "print('type: {}'.format(type(my_instance)))\n",
- "print('my_instance.name: {}'.format(my_instance.name))"
+ "mi_instancia = MiPrimerClase('John Doe')\n",
+ "print('mi_instancia: {}'.format(mi_instancia))\n",
+ "print('tipo: {}'.format(type(mi_instancia)))\n",
+ "print('mi_instancia.nombre: {}'.format(mi_instancia.nombre))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Methods\n",
- "The functions inside classes are called methods. They are used similarly as functions. "
+ "## Metodos\n",
+ "Las funciones dentro de clases son llamadas metodos. Son usadas de una forma similar a las funciones. "
]
},
{
@@ -47,8 +47,8 @@
"metadata": {},
"outputs": [],
"source": [
- "alice = MyFirstClass(name='Alice')\n",
- "alice.greet()"
+ "alicia = MiPrimerClase(nombre='Alicia')\n",
+ "alicia.saludar()"
]
},
{
@@ -56,7 +56,7 @@
"metadata": {},
"source": [
"### `__init__()`\n",
- "`__init__()` is a special method that is used for initialising instances of the class. It's called when you create an instance of the class. "
+ "`__init__()` es un metodo especial que es usado para inicializar instancias de la clase. Es llamado cuando se crea una instancia de la clase. "
]
},
{
@@ -65,20 +65,20 @@
"metadata": {},
"outputs": [],
"source": [
- "class Example:\n",
+ "class Ejemplo:\n",
" def __init__(self):\n",
- " print('Now we are inside __init__')\n",
+ " print('Ahora estamos dentro del __init__')\n",
" \n",
- "print('creating instance of Example')\n",
- "example = Example()\n",
- "print('instance created')"
+ "print('creando una instancia de Ejemplo')\n",
+ "ejemplo = Ejemplo()\n",
+ "print('instancia creada')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "`__init__()` is typically used for initialising instance variables of your class. These can be listed as arguments after `self`. To be able to access these instance variables later during your instance's lifetime, you have to save them into `self`. `self` is the first argument of the methods of your class and it's your access to the instance variables and other methods. "
+ "`__init__()` es tipicamente usado para inicializar variables de tu clase. Estas pueden ser listadas como argumentos después de `self`. Para poder acceder a estas variables de instancia durante la vida de tu instancia, tienen que guardarlas en `self`. `self` es el primer argumento de los metodos de tu clase y es tu acceso a las variables de la instancia y otros metodos. "
]
},
{
@@ -87,15 +87,15 @@
"metadata": {},
"outputs": [],
"source": [
- "class Example:\n",
+ "class Ejemplo:\n",
" def __init__(self, var1, var2):\n",
- " self.first_var = var1\n",
- " self.second_var = var2\n",
+ " self.primer_var = var1\n",
+ " self.segundo_var = var2\n",
" \n",
" def print_variables(self):\n",
- " print('{} {}'.format(self.first_var, self.second_var))\n",
+ " print('{} {}'.format(self.primer_var, self.segundo_var))\n",
" \n",
- "e = Example('abc', 123)\n",
+ "e = Ejemplo('abc', 123)\n",
"e.print_variables()\n",
" "
]
@@ -105,7 +105,7 @@
"metadata": {},
"source": [
"### `__str__()`\n",
- "`__str__()` is a special method which is called when an instance of the class is converted to string (e.g. when you want to print the instance). In other words, by defining `__str__` method for your class, you can decide what's the printable version of the instances of your class. The method should return a string."
+ "`__str__()` es un metodo especial que es llamado cuando una instancia de la clase es convertida a string (ej, cuando quieren imprimir la instancia). En otras palabras, definiendo el metodo `__str__` para tu clase, pueden decidir cual va a ser la versión imprimible de las instancias de tu clase. Este metodo debe devolver un string."
]
},
{
@@ -114,24 +114,24 @@
"metadata": {},
"outputs": [],
"source": [
- "class Person:\n",
- " def __init__(self, name, age):\n",
- " self.name = name\n",
- " self.age = age\n",
+ "class Persona:\n",
+ " def __init__(self, nombre, edad):\n",
+ " self.nombre = nombre\n",
+ " self.edad = edad\n",
" \n",
" def __str__(self):\n",
- " return 'Person: {}'.format(self.name)\n",
+ " return 'Persona: {}'.format(self.nombre)\n",
" \n",
- "jack = Person('Jack', 82)\n",
- "print('This is the string presentation of jack: {}'.format(jack))"
+ "jack = Persona('Jack', 82)\n",
+ "print('Esta es la representacion string de Jack: {}'.format(jack))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Class variables vs instance variables\n",
- "Class variables are shared between all the instances of that class whereas instance variables can hold different values between different instances of that class."
+ "## Variables de clase vs variables de instancia\n",
+ "Las variables de clase pueden ser compartidas por todas las instancias de esa clase mientras que las variables de una instancia pueden tener diferentes valores entre diferentes instancias de esa clase."
]
},
{
@@ -140,42 +140,42 @@
"metadata": {},
"outputs": [],
"source": [
- "class Example:\n",
- " # These are class variables\n",
- " name = 'Example class'\n",
- " description = 'Just an example of a simple class'\n",
+ "class Ejemplo:\n",
+ " # Estas son variables de clase\n",
+ " nombre = 'Clase Ejemplo'\n",
+ " descripcion = 'Solo un ejemplo de una clase simple'\n",
"\n",
" def __init__(self, var1):\n",
- " # This is an instance variable\n",
- " self.instance_variable = var1\n",
+ " # Esta es una variable de instancia\n",
+ " self.variable_instancia = var1\n",
"\n",
- " def show_info(self):\n",
- " info = 'instance_variable: {}, name: {}, description: {}'.format(\n",
- " self.instance_variable, Example.name, Example.description)\n",
+ " def mostrar_info(self):\n",
+ " info = 'variable_instancia: {}, nombre: {}, descripcion: {}'.format(\n",
+ " self.variable_instancia, Ejemplo.nombre, Ejemplo.descripcion)\n",
" print(info)\n",
"\n",
"\n",
- "inst1 = Example('foo')\n",
- "inst2 = Example('bar')\n",
+ "inst1 = Ejemplo('foo')\n",
+ "inst2 = Ejemplo('bar')\n",
"\n",
- "# name and description have identical values between instances\n",
- "assert inst1.name == inst2.name == Example.name\n",
- "assert inst1.description == inst2.description == Example.description\n",
+ "# nombre y descripcion tienen valores identicos entre instancias\n",
+ "assert inst1.nombre == inst2.nombre == Ejemplo.nombre\n",
+ "assert inst1.descripcion == inst2.descripcion == Ejemplo.descripcion\n",
"\n",
- "# If you change the value of a class variable, it's changed across all instances\n",
- "Example.name = 'Modified name'\n",
- "inst1.show_info()\n",
- "inst2.show_info()"
+ "# Si cambian el valor de una variable de clase, se cambia en todas las instancias\n",
+ "Ejemplo.nombre = 'Nombre modificado'\n",
+ "inst1.mostrar_info()\n",
+ "inst2.mostrar_info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Public vs private\n",
- "In python there's now strict separation for private/public methods or instance variables. The convention is to start the name of the method or instance variable with underscore if it should be treated as private. Private means that it should not be accessed from outside of the class.\n",
+ "## Publico vs privado\n",
+ "En python hay una separación estricta para metodos privados/publicos o variables de instancia. La convención es empezar el nombre del metodo o variable de instancia con guion bajo si debería ser tratada como privada. Privada significa que no puede ser accedida por fuera de la clase.\n",
"\n",
- "For example, let's consider that we have a `Person` class which has `age` as an instance variable. We want that `age` is not directly accessed (e.g. changed) after the instance is created. In Python, this would be:"
+ "Por ejemplo, consideremos que tenemos una clase `Persona` que tiene `edad` como una variable de instancia. Queremos que `edad` no sea directamente accedida (o cambiada) despues de que la instancia es creada. En Python esto sería:"
]
},
{
@@ -184,22 +184,22 @@
"metadata": {},
"outputs": [],
"source": [
- "class Person:\n",
- " def __init__(self, age):\n",
- " self._age = age\n",
+ "class Persona:\n",
+ " def __init__(self, edad):\n",
+ " self._edad = edad\n",
" \n",
- "example_person = Person(age=15)\n",
- "# You can't do this:\n",
- "# print(example_person.age)\n",
- "# Nor this:\n",
- "# example_person.age = 16"
+ "ejemplo_persona = Persona(edad=15)\n",
+ "# No pueden hacer esto:\n",
+ "# print(ejemplo_persona.edad)\n",
+ "# Ni esto:\n",
+ "# ejemplo_persona.edad = 16"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "If you want the `age` to be readable but not writable, you can use `property`:"
+ "Si quieren que `edad` pueda ser leido pero no escrito, pueden usar `property`:"
]
},
{
@@ -208,26 +208,26 @@
"metadata": {},
"outputs": [],
"source": [
- "class Person:\n",
- " def __init__(self, age):\n",
- " self._age = age\n",
+ "class Persona:\n",
+ " def __init__(self, edad):\n",
+ " self._edad = edad\n",
" \n",
" @property\n",
- " def age(self):\n",
- " return self._age\n",
+ " def edad(self):\n",
+ " return self._edad\n",
" \n",
- "example_person = Person(age=15)\n",
- "# Now you can do this:\n",
- "print(example_person.age)\n",
- "# But not this:\n",
- "#example_person.age = 16"
+ "ejemplo_persona = Persona(edad=15)\n",
+ "# Ahora pueden hacer esto:\n",
+ "print(ejemplo_persona.edad)\n",
+ "# Pero no esto:\n",
+ "#ejemplo_persona.edad = 16"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "This way you can have a controlled access to the instance variables of your class: "
+ "De esta forma tienen un acceso controlado a las variables de instancia de sus clases: "
]
},
{
@@ -236,27 +236,27 @@
"metadata": {},
"outputs": [],
"source": [
- "class Person:\n",
- " def __init__(self, age):\n",
- " self._age = age\n",
+ "class Persona:\n",
+ " def __init__(self, edad):\n",
+ " self._edad = edad\n",
" \n",
" @property\n",
- " def age(self):\n",
- " return self._age\n",
+ " def edad(self):\n",
+ " return self._edad\n",
" \n",
- " def celebrate_birthday(self):\n",
- " self._age += 1\n",
- " print('Happy bday for {} years old!'.format(self._age))\n",
+ " def celebrar_cumple(self):\n",
+ " self._edad += 1\n",
+ " print('Felices {} anios!'.format(self._edad))\n",
" \n",
- "example_person = Person(age=15)\n",
- "example_person.celebrate_birthday()"
+ "ejemplo_persona = Persona(edad=15)\n",
+ "ejemplo_persona.celebrar_cumple()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Introduction to inheritance"
+ "## Introducción a la herencia"
]
},
{
@@ -266,23 +266,23 @@
"outputs": [],
"source": [
"class Animal:\n",
- " def greet(self):\n",
- " print('Hello, I am an animal')\n",
+ " def saludar(self):\n",
+ " print('Hola, soy un animal')\n",
"\n",
" @property\n",
- " def favorite_food(self):\n",
- " return 'beef'\n",
+ " def comida_favorita(self):\n",
+ " return 'churrasco'\n",
"\n",
"\n",
- "class Dog(Animal):\n",
- " def greet(self):\n",
+ "class Perro(Animal):\n",
+ " def saludar(self):\n",
" print('wof wof')\n",
"\n",
"\n",
- "class Cat(Animal):\n",
+ "class Gato(Animal):\n",
" @property\n",
- " def favorite_food(self):\n",
- " return 'fish'"
+ " def comida_favorita(self):\n",
+ " return 'pez'"
]
},
{
@@ -291,23 +291,23 @@
"metadata": {},
"outputs": [],
"source": [
- "dog = Dog()\n",
- "dog.greet()\n",
- "print(\"Dog's favorite food is {}\".format(dog.favorite_food))\n",
+ "perro = Perro()\n",
+ "perro.saludar()\n",
+ "print(\"La comida favorita del perro es {}\".format(perro.comida_favorita))\n",
"\n",
- "cat = Cat()\n",
- "cat.greet()\n",
- "print(\"Cat's favorite food is {}\".format(cat.favorite_food))"
+ "gato = Gato()\n",
+ "gato.saludar()\n",
+ "print(\"La comida favorita del gato es {}\".format(gato.comida_favorita))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
- "language": "python",
+ "languedad": "python",
"name": "python3"
},
- "language_info": {
+ "languedad_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
diff --git a/notebooks/beginner/notebooks/conditionals.ipynb b/notebooks/beginner/notebooks/conditionals.ipynb
index 3850f20..1eaa1b2 100644
--- a/notebooks/beginner/notebooks/conditionals.ipynb
+++ b/notebooks/beginner/notebooks/conditionals.ipynb
@@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# Conditionals"
+ "# Condicionales"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Testing truth value"
+ "## Probando valores de verdad"
]
},
{
@@ -27,7 +27,7 @@
"metadata": {},
"outputs": [],
"source": [
- "print('type of True and False: {}'.format(type(True)))"
+ "print('tipo de True y False: {}'.format(type(True)))"
]
},
{
@@ -37,8 +37,8 @@
"outputs": [],
"source": [
"print('0: {}, 1: {}'.format(bool(0), bool(1)))\n",
- "print('empty list: {}, list with values: {}'.format(bool([]), bool(['woop'])))\n",
- "print('empty dict: {}, dict with values: {}'.format(bool({}), bool({'Python': 'cool'})))"
+ "print('lista vacia: {}, lista con valores: {}'.format(bool([]), bool(['asd'])))\n",
+ "print('diccionario vacio: {}, diccionario con valores: {}'.format(bool({}), bool({'Python': 'genial'})))"
]
},
{
@@ -70,7 +70,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "You can combine these:"
+ "Pueden combinarlos:"
]
},
{
@@ -95,10 +95,10 @@
"metadata": {},
"outputs": [],
"source": [
- "python_is_cool = True\n",
- "java_is_cool = False\n",
- "empty_list = []\n",
- "secret_value = 3.14"
+ "python_es_genial = True\n",
+ "java_es_genial = False\n",
+ "lista_vacia = []\n",
+ "valor_secreto = 3.14"
]
},
{
@@ -107,8 +107,8 @@
"metadata": {},
"outputs": [],
"source": [
- "print('Python and java are both cool: {}'.format(python_is_cool and java_is_cool))\n",
- "print('secret_value and python_is_cool: {}'.format(secret_value and python_is_cool))"
+ "print('Python y Java son geniales los dos: {}'.format(python_es_genial and java_es_genial))\n",
+ "print('valor_secreto y python_es_genial: {}'.format(valor_secreto and python_es_genial))"
]
},
{
@@ -117,7 +117,7 @@
"metadata": {},
"outputs": [],
"source": [
- "print('Python or java is cool: {}'.format(python_is_cool or java_is_cool))\n",
+ "print('Python o java es genial: {}'.format(python_es_genial or java_es_genial))\n",
"print('1 >= 1.1 or 2 < float(\"1.4\"): {}'.format(1 >= 1.1 or 2 < float('1.4')))"
]
},
@@ -127,14 +127,14 @@
"metadata": {},
"outputs": [],
"source": [
- "print('Java is not cool: {}'.format(not java_is_cool))"
+ "print('Java no es genial: {}'.format(not java_es_genial))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "You can combine multiple statements, execution order is from left to right. You can control the execution order by using brackets."
+ "Pueden combinar múltiples declaraciones, el orden de ejecución es de izquierda a derecha. Pueden controlar el orden usando paréntesis."
]
},
{
@@ -143,8 +143,8 @@
"metadata": {},
"outputs": [],
"source": [
- "print(bool(not java_is_cool or secret_value and python_is_cool or empty_list))\n",
- "print(bool(not (java_is_cool or secret_value and python_is_cool or empty_list)))"
+ "print(bool(not java_es_genial or valor_secreto and python_es_genial or lista_vacia))\n",
+ "print(bool(not (java_es_genial or valor_secreto and python_es_genial or lista_vacia)))"
]
},
{
@@ -160,12 +160,12 @@
"metadata": {},
"outputs": [],
"source": [
- "statement = True\n",
- "if statement:\n",
- " print('statement is True')\n",
+ "declaracion = True\n",
+ "if declaracion:\n",
+ " print('declaracion is True')\n",
" \n",
- "if not statement:\n",
- " print('statement is not True')"
+ "if not declaracion:\n",
+ " print('declaracion is not True')"
]
},
{
@@ -174,10 +174,10 @@
"metadata": {},
"outputs": [],
"source": [
- "empty_list = []\n",
- "# With if and elif, conversion to `bool` is implicit\n",
- "if empty_list:\n",
- " print('empty list will not evaluate to True') # this won't be executed"
+ "lista_vacia = []\n",
+ "# Con if y elif, la conversión a `bool` es implicita es implicita\n",
+ "if lista_vacia:\n",
+ " print('lista vacia no va a evaluar a True') # esto no va a ser ejecutado"
]
},
{
@@ -188,7 +188,7 @@
"source": [
"val = 3\n",
"if 0 <= val < 1 or val == 3:\n",
- " print('Value is positive and less than one or value is three')"
+ " print('El valor es positivo y menor a uno o el valor es tres')"
]
},
{
@@ -204,11 +204,11 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {}\n",
- "if my_dict:\n",
- " print('there is something in my dict')\n",
+ "mi_dict = {}\n",
+ "if mi_dict:\n",
+ " print('hay algo en mi diccionario')\n",
"else:\n",
- " print('my dict is empty :(')"
+ " print('mi diccionario esta vacio :(')"
]
},
{
@@ -226,18 +226,18 @@
"source": [
"val = 88\n",
"if val >= 100:\n",
- " print('value is equal or greater than 100')\n",
+ " print('valor es igual o mayor a 100')\n",
"elif val > 10:\n",
- " print('value is greater than 10 but less than 100')\n",
+ " print('valor es mayor a 10 pero menor a 100')\n",
"else:\n",
- " print('value is equal or less than 10')"
+ " print('valor es igual o menor a 10')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "You can have as many `elif` statements as you need. In addition, `else` at the end is not mandatory."
+ "Pueden tener tantos `elif`s como necesiten. A propósito, el `else` al final no es obligatorio."
]
},
{
@@ -246,26 +246,26 @@
"metadata": {},
"outputs": [],
"source": [
- "greeting = 'Hello fellow Pythonista!'\n",
- "language = 'Italian'\n",
+ "saludo = 'Hola compañero Pythonita!'\n",
+ "language = 'Italiano'\n",
"\n",
- "if language == 'Swedish':\n",
- " greeting = 'Hejsan!'\n",
- "elif language == 'Finnish':\n",
- " greeting = 'Latua perkele!'\n",
- "elif language == 'Spanish':\n",
- " greeting = 'Hola!'\n",
- "elif language == 'German':\n",
- " greeting = 'Guten Tag!'\n",
+ "if language == 'Sueco':\n",
+ " saludo = 'Hejsan!'\n",
+ "elif language == 'Finlandes':\n",
+ " saludo = 'Latua perkele!'\n",
+ "elif language == 'Español':\n",
+ " saludo = 'Hola!'\n",
+ "elif language == 'Aleman':\n",
+ " saludo = 'Guten Tag!'\n",
" \n",
- "print(greeting)"
+ "print(saludo)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "For more detailed overview about conditionals, check this [tutorial from Real Python](https://realpython.com/python-conditional-statements/)."
+ "Para más información sobre Condicionales, pueden ver esta [documentacion](http://www.mclibre.org/consultar/python/lecciones/python-if-else.html)."
]
}
],
diff --git a/notebooks/beginner/notebooks/dictionaries.ipynb b/notebooks/beginner/notebooks/dictionaries.ipynb
index f1b4f39..e2fd64b 100644
--- a/notebooks/beginner/notebooks/dictionaries.ipynb
+++ b/notebooks/beginner/notebooks/dictionaries.ipynb
@@ -4,8 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# [Dictionaries](https://docs.python.org/3/library/stdtypes.html#dict) \n",
- "Collections of `key`-`value` pairs. "
+ "# [Diccionarios](https://docs.python.org/3/library/stdtypes.html#dict) \n",
+ "Colecciones de pares `llave`-`valor`. "
]
},
{
@@ -14,15 +14,15 @@
"metadata": {},
"outputs": [],
"source": [
- "my_empty_dict = {} # alternative: my_empty_dict = dict()\n",
- "print('dict: {}, type: {}'.format(my_empty_dict, type(my_empty_dict)))"
+ "mi_dicc_vacio = {} # alternative: mi_dicc_vacio = dict()\n",
+ "print('dicc: {}, tipo: {}'.format(mi_dicc_vacio, type(mi_dicc_vacio)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Initialization"
+ "## Inicialización"
]
},
{
@@ -31,14 +31,14 @@
"metadata": {},
"outputs": [],
"source": [
- "dict1 = {'value1': 1.6, 'value2': 10, 'name': 'John Doe'}\n",
- "dict2 = dict(value1=1.6, value2=10, name='John Doe')\n",
+ "dicc1 = {'valor1': 1.6, 'valor2': 10, 'nombre': 'John Doe'}\n",
+ "dicc2 = dict(valor1=1.6, valor2=10, nombre='John Doe')\n",
"\n",
- "print(dict1)\n",
- "print(dict2)\n",
+ "print(dicc1)\n",
+ "print(dicc2)\n",
"\n",
- "print('equal: {}'.format(dict1 == dict2))\n",
- "print('length: {}'.format(len(dict1)))"
+ "print('igual: {}'.format(dicc1 == dicc2))\n",
+ "print('longitud: {}'.format(len(dicc1)))"
]
},
{
@@ -54,16 +54,16 @@
"metadata": {},
"outputs": [],
"source": [
- "print('keys: {}'.format(dict1.keys()))\n",
- "print('values: {}'.format(dict1.values()))\n",
- "print('items: {}'.format(dict1.items()))"
+ "print('llaves: {}'.format(dicc1.keys()))\n",
+ "print('valores: {}'.format(dicc1.values()))\n",
+ "print('items: {}'.format(dicc1.items()))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Accessing and setting values"
+ "## Accediendo y seteando valores"
]
},
{
@@ -72,19 +72,19 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {}\n",
- "my_dict['key1'] = 'value1'\n",
- "my_dict['key2'] = 99\n",
- "my_dict['key1'] = 'new value' # overriding existing value\n",
- "print(my_dict)\n",
- "print('value of key1: {}'.format(my_dict['key1']))"
+ "mi_dicc = {}\n",
+ "mi_dicc['llave1'] = 'valor1'\n",
+ "mi_dicc['llave2'] = 99\n",
+ "mi_dicc['llave1'] = 'nuevo valor' # reemplazando el valor existente\n",
+ "print(mi_dicc)\n",
+ "print('valor de llave1: {}'.format(mi_dicc['llave1']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Accessing a nonexistent key will raise `KeyError` (see [`dict.get()`](#dict_get) for workaround):"
+ "Accediendo una llave no existente nos va a dar `KeyError` (vean [`dict.get()`](#dict_get) para buscarle la vuelta):"
]
},
{
@@ -93,14 +93,14 @@
"metadata": {},
"outputs": [],
"source": [
- "# print(my_dict['nope'])"
+ "# print(mi_dicc['nop'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Deleting"
+ "## Borrando"
]
},
{
@@ -109,23 +109,23 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {'key1': 'value1', 'key2': 99, 'keyX': 'valueX'}\n",
- "del my_dict['keyX']\n",
- "print(my_dict)\n",
+ "mi_dicc = {'llave1': 'valor1', 'llave2': 99, 'llaveX': 'valorX'}\n",
+ "del mi_dicc['llaveX']\n",
+ "print(mi_dicc)\n",
"\n",
- "# Usually better to make sure that the key exists (see also pop() and popitem())\n",
- "key_to_delete = 'my_key'\n",
- "if key_to_delete in my_dict:\n",
- " del my_dict[key_to_delete]\n",
+ "# Usualmente es mejor asegurarse que la llave existe (vean también pop() y popitem())\n",
+ "llave_a_eliminar = 'mi_llave'\n",
+ "if llave_a_eliminar in mi_dicc:\n",
+ " del mi_dicc[llave_a_eliminar]\n",
"else:\n",
- " print('{key} is not in {dictionary}'.format(key=key_to_delete, dictionary=my_dict))"
+ " print('{llave} no esta en {diccionario}'.format(llave=llave_a_eliminar, diccionario=mi_dicc))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Dictionaries are mutable"
+ "## Los diccionarios son mutables"
]
},
{
@@ -134,12 +134,12 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {'ham': 'good', 'carrot': 'semi good'}\n",
- "my_other_dict = my_dict\n",
- "my_other_dict['carrot'] = 'super tasty'\n",
- "my_other_dict['sausage'] = 'best ever'\n",
- "print('my_dict: {}\\nother: {}'.format(my_dict, my_other_dict))\n",
- "print('equal: {}'.format(my_dict == my_other_dict))"
+ "mi_dicc = {'jamon': 'bueno', 'zanahoria': 'casi buena'}\n",
+ "mi_otro_dicc = mi_dicc\n",
+ "mi_otro_dicc['zanahoria'] = 'muy rica'\n",
+ "mi_otro_dicc['patty'] = 'lo mejor'\n",
+ "print('mi_dicc: {}\\notro: {}'.format(mi_dicc, mi_otro_dicc))\n",
+ "print('igual: {}'.format(mi_dicc == mi_otro_dicc))"
]
},
{
@@ -155,11 +155,11 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {'ham': 'good', 'carrot': 'semi good'}\n",
- "my_other_dict = dict(my_dict)\n",
- "my_other_dict['beer'] = 'decent'\n",
- "print('my_dict: {}\\nother: {}'.format(my_dict, my_other_dict))\n",
- "print('equal: {}'.format(my_dict == my_other_dict))"
+ "mi_dicc = {'jamon': 'bueno', 'zanahoria': 'casi buena'}\n",
+ "mi_otro_dicc = dict(mi_dicc)\n",
+ "mi_otro_dicc['cerveza'] = 'decente'\n",
+ "print('mi_dicc: {}\\notro: {}'.format(mi_dicc, mi_otro_dicc))\n",
+ "print('igual: {}'.format(mi_dicc == mi_otro_dicc))"
]
},
{
@@ -168,7 +168,7 @@
"source": [
"\n",
"## `dict.get()`\n",
- "Returns `None` if `key` is not in `dict`. However, you can also specify `default` return value which will be returned if `key` is not present in the `dict`. "
+ "Devuelve `None` si `llave` no esta en `dicc`. Sin embargo, pueden especificar un valor `por defecto` que será devuelto si `llave` no está presente en el `dicc`. "
]
},
{
@@ -177,11 +177,11 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {'a': 1, 'b': 2, 'c': 3}\n",
- "d = my_dict.get('d')\n",
+ "mi_dicc = {'a': 1, 'b': 2, 'c': 3}\n",
+ "d = mi_dicc.get('d')\n",
"print('d: {}'.format(d))\n",
"\n",
- "d = my_dict.get('d', 'my default value')\n",
+ "d = mi_dicc.get('d', 'mi valor por defecto')\n",
"print('d: {}'.format(d))"
]
},
@@ -198,16 +198,16 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = dict(food='ham', drink='beer', sport='football')\n",
- "print('dict before pops: {}'.format(my_dict))\n",
+ "mi_dicc = dict(comida='jamon', bebida='cerveza', deporte='football')\n",
+ "print('dicc antes de aplicar pop: {}'.format(mi_dicc))\n",
"\n",
- "food = my_dict.pop('food')\n",
- "print('food: {}'.format(food))\n",
- "print('dict after popping food: {}'.format(my_dict))\n",
+ "comida = mi_dicc.pop('comida')\n",
+ "print('comida: {}'.format(comida))\n",
+ "print('diccionario despues de aplicar pop: {}'.format(mi_dicc))\n",
"\n",
- "food_again = my_dict.pop('food', 'default value for food')\n",
- "print('food again: {}'.format(food_again))\n",
- "print('dict after popping food again: {}'.format(my_dict))\n"
+ "comida_denuevo = mi_dicc.pop('comida', 'valor por defecto para comida')\n",
+ "print('comida de nuevo: {}'.format(comida_denuevo))\n",
+ "print('diccionario despues de aplicar pop otra vez: {}'.format(mi_dicc))\n"
]
},
{
@@ -215,7 +215,7 @@
"metadata": {},
"source": [
"## `dict.setdefault()`\n",
- "Returns the `value` of `key` defined as first parameter. If the `key` is not present in the dict, adds `key` with default value (second parameter)."
+ "Devuelve el `valor` de `llave` definida como primer parametro. Si `llave` no está en el diccionario, añade `llave` con un valor por defecto (segundo parametro)."
]
},
{
@@ -224,10 +224,10 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {'a': 1, 'b': 2, 'c': 3}\n",
- "a = my_dict.setdefault('a', 'my default value')\n",
- "d = my_dict.setdefault('d', 'my default value')\n",
- "print('a: {}\\nd: {}\\nmy_dict: {}'.format(a, d, my_dict))"
+ "mi_dicc = {'a': 1, 'b': 2, 'c': 3}\n",
+ "a = mi_dicc.setdefault('a', 'mi valor por defecto')\n",
+ "d = mi_dicc.setdefault('d', 'mi valor por defecto')\n",
+ "print('a: {}\\nd: {}\\nmi_dicc: {}'.format(a, d, mi_dicc))"
]
},
{
@@ -235,7 +235,7 @@
"metadata": {},
"source": [
"## `dict.update()`\n",
- "Merge two `dict`s"
+ "Combina dos `dicc`s"
]
},
{
@@ -244,28 +244,28 @@
"metadata": {},
"outputs": [],
"source": [
- "dict1 = {'a': 1, 'b': 2}\n",
- "dict2 = {'c': 3}\n",
- "dict1.update(dict2)\n",
- "print(dict1)\n",
+ "dicc1 = {'a': 1, 'b': 2}\n",
+ "dicc2 = {'c': 3}\n",
+ "dicc1.update(dicc2)\n",
+ "print(dicc1)\n",
"\n",
- "# If they have same keys:\n",
- "dict1.update({'c': 4})\n",
- "print(dict1)"
+ "# Si tienen las mismas llaves:\n",
+ "dicc1.update({'c': 4})\n",
+ "print(dicc1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## The keys of a `dict` have to be immutable"
+ "## Las llaves de un `dicc` tienen que ser inmutables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Thus you can not use e.g. a `list` or a `dict` as key because they are mutable types\n",
+ "Por lo que no podemos usar, por ejemplo, una `lista` o un `dicc` como llaves porque son tipos mutables\n",
":"
]
},
@@ -275,14 +275,14 @@
"metadata": {},
"outputs": [],
"source": [
- "# bad_dict = {['my_list'], 'value'} # Raises TypeError"
+ "# mal_dicc = {['mi_lista'], 'valor'} # Tira TypeError"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Values can be mutable"
+ "Los valores pueden ser mutables"
]
},
{
@@ -291,8 +291,8 @@
"metadata": {},
"outputs": [],
"source": [
- "good_dict = {'my key': ['Python', 'is', 'still', 'cool']}\n",
- "print(good_dict)"
+ "buen_dicc = {'mi llave': ['Python', 'es', 'divertido', '(ponele)']}\n",
+ "print(buen_dicc)"
]
}
],
diff --git a/notebooks/beginner/notebooks/file_io.ipynb b/notebooks/beginner/notebooks/file_io.ipynb
index 76c8ee2..d82f595 100644
--- a/notebooks/beginner/notebooks/file_io.ipynb
+++ b/notebooks/beginner/notebooks/file_io.ipynb
@@ -4,15 +4,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# [File I/O](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files)\n",
- "Reading and writing files."
+ "# [Archivos I/O](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files)\n",
+ "Leyendo y escribiendo archivos."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Working with paths"
+ "## Trabajando con rutas"
]
},
{
@@ -23,23 +23,23 @@
"source": [
"import os\n",
"\n",
- "current_file = os.path.realpath('file_io.ipynb') \n",
- "print('current file: {}'.format(current_file))\n",
- "# Note: in .py files you can get the path of current file by __file__\n",
+ "archivo_actual = os.path.realpath('file_io.ipynb') \n",
+ "print('archivo actual: {}'.format(archivo_actual))\n",
+ "# Nota: en archivos .py pueden obtener la ruta del archivo actual con __file__\n",
"\n",
- "current_dir = os.path.dirname(current_file) \n",
- "print('current directory: {}'.format(current_dir))\n",
- "# Note: in .py files you can get the dir of current file by os.path.dirname(__file__)\n",
+ "dir_actual = os.path.dirname(archivo_actual) \n",
+ "print('directorio actual: {}'.format(dir_actual))\n",
+ "# Note: en archivos .py pueden obtener el directorio del archivo actual con os.path.dirname(__file__)\n",
"\n",
- "data_dir = os.path.join(os.path.dirname(current_dir), 'data')\n",
- "print('data directory: {}'.format(data_dir))"
+ "dir_data = os.path.join(os.path.dirname(dir_actual), 'data')\n",
+ "print('directorio de data: {}'.format(dir_data))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Checking if path exists"
+ "### Verificando si la ruta existe"
]
},
{
@@ -48,16 +48,16 @@
"metadata": {},
"outputs": [],
"source": [
- "print('exists: {}'.format(os.path.exists(data_dir)))\n",
- "print('is file: {}'.format(os.path.isfile(data_dir)))\n",
- "print('is directory: {}'.format(os.path.isdir(data_dir)))"
+ "print('existe: {}'.format(os.path.exists(dir_data)))\n",
+ "print('es archivo: {}'.format(os.path.isfile(dir_data)))\n",
+ "print('es directorio: {}'.format(os.path.isdir(dir_data)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Reading files"
+ "## Leyendo archivos"
]
},
{
@@ -66,22 +66,22 @@
"metadata": {},
"outputs": [],
"source": [
- "file_path = os.path.join(data_dir, 'simple_file.txt')\n",
+ "ruta_archivo = os.path.join(dir_data, 'archivo_simple.txt')\n",
"\n",
- "with open(file_path, 'r') as simple_file:\n",
- " for line in simple_file:\n",
- " print(line.strip())"
+ "with open(ruta_archivo, 'r') as archivo_simple:\n",
+ " for linea in archivo_simple:\n",
+ " print(linea.strip())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The [`with`](https://docs.python.org/3/reference/compound_stmts.html#the-with-statement) statement is for obtaining a [context manager](https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers) that will be used as an execution context for the commands inside the `with`. Context managers guarantee that certain operations are done when exiting the context. \n",
+ "La declaración [`with`](https://docs.python.org/3/reference/compound_stmts.html#the-with-statement) es para obtener un [context manager](https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers) que sera usado como un contexto de evaluación para los comandos dentro del `with`. Los context managers garantizan que ciertas operaciones sean hechas cuando se sale del contexto. \n",
"\n",
- "In this case, the context manager guarantees that `simple_file.close()` is implicitly called when exiting the context. This is a way to make developers life easier: you don't have to remember to explicitly close the file you openened nor be worried about an exception occuring while the file is open. Unclosed file maybe a source of a resource leak. Thus, prefer using `with open()` structure always with file I/O.\n",
+ "En este caso, el context manager garantiza que `archivo_simple.close()` sea llamado implicitamente cuando se salga del contexto. Esta es una forma de hacer la vida de los desarrolladores más fácil: no tenemos que acordarnos de cerrar explicitamente el archivo que abrimos ni tenemos que preocuparnos que alguna excepción ocurra mientras que el archivo esté abierto. Archivos que estén sin cerrar pueden ser una fuente de 'fuga' de recursos. Por lo tanto, procuren usar la estructura `with open()` siempre cuando interactuen con I/O.\n",
"\n",
- "To have an example, the same as above without the `with`."
+ "Para tener un ejemplo, lo mismo que arriba pero sin el `with`."
]
},
{
@@ -90,20 +90,20 @@
"metadata": {},
"outputs": [],
"source": [
- "file_path = os.path.join(data_dir, 'simple_file.txt')\n",
+ "ruta_archivo = os.path.join(dir_data, 'archivo_simple.txt')\n",
"\n",
- "# THIS IS NOT THE PREFERRED WAY\n",
- "simple_file = open(file_path, 'r')\n",
- "for line in simple_file:\n",
- " print(line.strip())\n",
- "simple_file.close() # This has to be called explicitly "
+ "# ESTA NO ES LA FORMA QUE DEBERIAN USAR\n",
+ "archivo_simple = open(ruta_archivo, 'r')\n",
+ "for linea in archivo_simple:\n",
+ " print(linea.strip())\n",
+ "archivo_simple.close() # Esto tiene que ser llamado explicitamente "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Writing files"
+ "## Escribiendo archivos"
]
},
{
@@ -112,17 +112,17 @@
"metadata": {},
"outputs": [],
"source": [
- "new_file_path = os.path.join(data_dir, 'new_file.txt')\n",
+ "nueva_ruta_archivo = os.path.join(dir_data, 'nuevo_archivo.txt')\n",
"\n",
- "with open(new_file_path, 'w') as my_file:\n",
- " my_file.write('This is my first file that I wrote with Python.')"
+ "with open(nueva_ruta_archivo, 'w') as mi_archivo:\n",
+ " mi_archivo.write('Este es el primer archivo que hago con Python.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Now go and check that there is a new_file.txt in the data directory. After that you can delete the file by:"
+ "Ahora fijense si hay un archivo llamado nuevo_archivo.txt en el directorio data. Después que se fijen pueden borrar el archivo haciendo:"
]
},
{
@@ -131,8 +131,8 @@
"metadata": {},
"outputs": [],
"source": [
- "if os.path.exists(new_file_path): # make sure it's there\n",
- " os.remove(new_file_path)"
+ "if os.path.exists(nueva_ruta_archivo): # nos aseguramos que este ahi\n",
+ " os.remove(nueva_ruta_archivo)"
]
}
],
diff --git a/notebooks/beginner/notebooks/for_loops.ipynb b/notebooks/beginner/notebooks/for_loops.ipynb
index a61c1c1..d013695 100644
--- a/notebooks/beginner/notebooks/for_loops.ipynb
+++ b/notebooks/beginner/notebooks/for_loops.ipynb
@@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# [`for` loops](https://docs.python.org/3/tutorial/controlflow.html#for-statements)"
+ "# [Bucles `for`](https://docs.python.org/3/tutorial/controlflow.html#for-statements)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Looping lists"
+ "## Iterando listas"
]
},
{
@@ -20,8 +20,8 @@
"metadata": {},
"outputs": [],
"source": [
- "my_list = [1, 2, 3, 4, 'Python', 'is', 'neat']\n",
- "for item in my_list:\n",
+ "mi_lista = [1, 2, 3, 4, 'Python', 'es', 'piola']\n",
+ "for item in mi_lista:\n",
" print(item)"
]
},
@@ -30,7 +30,7 @@
"metadata": {},
"source": [
"### `break`\n",
- "Stop the execution of the loop."
+ "Parar la ejecución del bucle."
]
},
{
@@ -39,7 +39,7 @@
"metadata": {},
"outputs": [],
"source": [
- "for item in my_list:\n",
+ "for item in mi_lista:\n",
" if item == 'Python':\n",
" break\n",
" print(item)"
@@ -50,7 +50,7 @@
"metadata": {},
"source": [
"### `continue`\n",
- "Continue to the next item without executing the lines occuring after `continue` inside the loop."
+ "Continúa al próximo item sin ejecutar las lineas después de `continue` dentro del bucle."
]
},
{
@@ -59,7 +59,7 @@
"metadata": {},
"outputs": [],
"source": [
- "for item in my_list:\n",
+ "for item in mi_lista:\n",
" if item == 1:\n",
" continue\n",
" print(item)"
@@ -70,7 +70,7 @@
"metadata": {},
"source": [
"### `enumerate()`\n",
- "In case you need to also know the index:"
+ "En caso de que también necesiten saber el indice:"
]
},
{
@@ -79,15 +79,15 @@
"metadata": {},
"outputs": [],
"source": [
- "for idx, val in enumerate(my_list):\n",
- " print('idx: {}, value: {}'.format(idx, val))"
+ "for indice, valor in enumerate(mi_lista):\n",
+ " print('indice: {}, valoror: {}'.format(indice, valor))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Looping dictionaries"
+ "## Iterando diccionarios"
]
},
{
@@ -96,9 +96,9 @@
"metadata": {},
"outputs": [],
"source": [
- "my_dict = {'hacker': True, 'age': 72, 'name': 'John Doe'}\n",
- "for val in my_dict:\n",
- " print(val)"
+ "mi_dicc = {'hacker': True, 'edad': 72, 'nombre': 'John Doe'}\n",
+ "for valor in mi_dicc:\n",
+ " print(valor)"
]
},
{
@@ -107,8 +107,8 @@
"metadata": {},
"outputs": [],
"source": [
- "for key, val in my_dict.items():\n",
- " print('{}={}'.format(key, val))"
+ "for llave, valor in mi_dicc.items():\n",
+ " print('{}={}'.format(llave, valor))"
]
},
{
@@ -124,8 +124,8 @@
"metadata": {},
"outputs": [],
"source": [
- "for number in range(5):\n",
- " print(number)"
+ "for numero in range(5):\n",
+ " print(numero)"
]
},
{
@@ -134,8 +134,8 @@
"metadata": {},
"outputs": [],
"source": [
- "for number in range(2, 5):\n",
- " print(number)"
+ "for numero in range(2, 5):\n",
+ " print(numero)"
]
},
{
@@ -144,8 +144,8 @@
"metadata": {},
"outputs": [],
"source": [
- "for number in range(0, 10, 2): # last one is step\n",
- " print(number)"
+ "for numero in range(0, 10, 2): # el ultimo son los pasos\n",
+ " print(numero)"
]
}
],
diff --git a/notebooks/beginner/notebooks/functions.ipynb b/notebooks/beginner/notebooks/functions.ipynb
index ca00f31..20e2bb7 100644
--- a/notebooks/beginner/notebooks/functions.ipynb
+++ b/notebooks/beginner/notebooks/functions.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# Functions"
+ "# Funciones"
]
},
{
@@ -13,19 +13,19 @@
"metadata": {},
"outputs": [],
"source": [
- "def my_first_function():\n",
- " print('Hello world!')\n",
+ "def mi_primera_funcion():\n",
+ " print('Hola mundo!')\n",
"\n",
- "print('type: {}'.format(my_first_function))\n",
+ "print('type: {}'.format(mi_primera_funcion))\n",
"\n",
- "my_first_function() # Calling a function"
+ "mi_primera_funcion() # Calling a function"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Arguments"
+ "### Argumentos"
]
},
{
@@ -34,10 +34,10 @@
"metadata": {},
"outputs": [],
"source": [
- "def greet_us(name1, name2):\n",
- " print('Hello {} and {}!'.format(name1, name2))\n",
+ "def saludar(nombre1, nombre2):\n",
+ " print('Hola {} y {}!'.format(nombre1, nombre2))\n",
"\n",
- "greet_us('John Doe', 'Superman')"
+ "saludar('John Doe', 'Superman')"
]
},
{
@@ -46,21 +46,21 @@
"metadata": {},
"outputs": [],
"source": [
- "# Function with return value\n",
- "def strip_and_lowercase(original):\n",
- " modified = original.strip().lower()\n",
- " return modified\n",
+ "# Funcion con valor devuelto\n",
+ "def desnudar_y_convertir_minusculas(original):\n",
+ " modificado = original.strip().lower()\n",
+ " return modificado\n",
"\n",
- "uggly_string = ' MixED CaSe '\n",
- "pretty = strip_and_lowercase(uggly_string)\n",
- "print('pretty: {}'.format(pretty))"
+ "string_feo = ' StRiNg MEzClaDo '\n",
+ "lindo = desnudar_y_convertir_minusculas(string_feo)\n",
+ "print('lindo: {}'.format(lindo))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Keyword arguments"
+ "### Argumentos con nombre"
]
},
{
@@ -69,25 +69,25 @@
"metadata": {},
"outputs": [],
"source": [
- "def my_fancy_calculation(first, second, third):\n",
- " return first + second - third \n",
+ "def mi_calculo_loco(primero, segundo, tercero):\n",
+ " return primero + segundo - tercero \n",
"\n",
- "print(my_fancy_calculation(3, 2, 1))\n",
+ "print(mi_calculo_loco(3, 2, 1))\n",
"\n",
- "print(my_fancy_calculation(first=3, second=2, third=1))\n",
+ "print(mi_calculo_loco(primero=3, segundo=2, tercero=1))\n",
"\n",
- "# With keyword arguments you can mix the order\n",
- "print(my_fancy_calculation(third=1, first=3, second=2))\n",
+ "# Con argumentos con nombre se puede mezclar el orden\n",
+ "print(mi_calculo_loco(tercero=1, primero=3, segundo=2))\n",
"\n",
- "# You can mix arguments and keyword arguments but you have to start with arguments\n",
- "print(my_fancy_calculation(3, third=1, second=2)) "
+ "# Pueden mezclar argumentos normales y argumentos con nombre pero siempre tienen que ir primero los argumentos normales\n",
+ "print(mi_calculo_loco(3, tercero=1, segundo=2)) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Default arguments"
+ "### Argumentos por defecto"
]
},
{
@@ -98,17 +98,17 @@
},
"outputs": [],
"source": [
- "def create_person_info(name, age, job=None, salary=300):\n",
- " info = {'name': name, 'age': age, 'salary': salary}\n",
+ "def crear_info_persona(nombre, edad, trabajo=None, sueldo=300):\n",
+ " info = {'nombre': nombre, 'edad': edad, 'sueldo': sueldo}\n",
" \n",
- " # Add 'job' key only if it's provided as parameter\n",
- " if job: \n",
- " info.update(dict(job=job))\n",
+ " # Añado la llave 'trabajo' solo si se dio como parametro\n",
+ " if trabajo: \n",
+ " info.update(dict(trabajo=trabajo))\n",
" \n",
" return info\n",
"\n",
- "person1 = create_person_info('John Doe', 82) # use default values for job and salary\n",
- "person2 = create_person_info('Lisa Doe', 22, 'hacker', 10000)\n",
+ "person1 = crear_info_persona('John Doe', 82) # uso los valores por defecto de trabajo y sueldo\n",
+ "person2 = crear_info_persona('Lisa Doe', 22, 'hacker', 10000)\n",
"print(person1)\n",
"print(person2)"
]
@@ -117,7 +117,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "**Don't use mutable objects as default arguments!**"
+ "**No usen objetos mutables como argumentos por defecto!!**"
]
},
{
@@ -126,23 +126,23 @@
"metadata": {},
"outputs": [],
"source": [
- "def append_if_multiple_of_five(number, magical_list=[]):\n",
- " if number % 5 == 0:\n",
- " magical_list.append(number)\n",
- " return magical_list\n",
+ "def append_si_es_multiplo_de_5(numero, lista_magica=[]):\n",
+ " if numero % 5 == 0:\n",
+ " lista_magica.append(numero)\n",
+ " return lista_magica\n",
"\n",
- "print(append_if_multiple_of_five(100))\n",
- "print(append_if_multiple_of_five(105))\n",
- "print(append_if_multiple_of_five(123))\n",
- "print(append_if_multiple_of_five(123, []))\n",
- "print(append_if_multiple_of_five(123))"
+ "print(append_si_es_multiplo_de_5(100))\n",
+ "print(append_si_es_multiplo_de_5(105))\n",
+ "print(append_si_es_multiplo_de_5(123))\n",
+ "print(append_si_es_multiplo_de_5(123, []))\n",
+ "print(append_si_es_multiplo_de_5(123))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Here's how you can achieve desired behavior:"
+ "Así sería si lo quisieramos hacer bien:"
]
},
{
@@ -151,18 +151,18 @@
"metadata": {},
"outputs": [],
"source": [
- "def append_if_multiple_of_five(number, magical_list=None):\n",
- " if not magical_list:\n",
- " magical_list = []\n",
- " if number % 5 == 0:\n",
- " magical_list.append(number)\n",
- " return magical_list\n",
+ "def append_si_es_multiplo_de_5(numero, lista_magica=None):\n",
+ " if not lista_magica:\n",
+ " lista_magica = []\n",
+ " if numero % 5 == 0:\n",
+ " lista_magica.append(numero)\n",
+ " return lista_magica\n",
"\n",
- "print(append_if_multiple_of_five(100))\n",
- "print(append_if_multiple_of_five(105))\n",
- "print(append_if_multiple_of_five(123))\n",
- "print(append_if_multiple_of_five(123, []))\n",
- "print(append_if_multiple_of_five(123))"
+ "print(append_si_es_multiplo_de_5(100))\n",
+ "print(append_si_es_multiplo_de_5(105))\n",
+ "print(append_si_es_multiplo_de_5(123))\n",
+ "print(append_si_es_multiplo_de_5(123, []))\n",
+ "print(append_si_es_multiplo_de_5(123))"
]
},
{
@@ -170,7 +170,7 @@
"metadata": {},
"source": [
"### Docstrings\n",
- "Strings for documenting your functions, methods, modules and variables."
+ "Strings para documentar funciones, metodos, modulos y variables."
]
},
{
@@ -179,11 +179,11 @@
"metadata": {},
"outputs": [],
"source": [
- "def print_sum(val1, val2):\n",
- " \"\"\"Function which prints the sum of given arguments.\"\"\"\n",
- " print('sum: {}'.format(val1 + val2))\n",
+ "def imprimir_suma(val1, val2):\n",
+ " \"\"\"Funcion que imprime la suma de los argumentos dados.\"\"\"\n",
+ " print('suma: {}'.format(val1 + val2))\n",
"\n",
- "print(help(print_sum))"
+ "print(help(imprimir_suma))"
]
},
{
@@ -192,28 +192,28 @@
"metadata": {},
"outputs": [],
"source": [
- "def calculate_sum(val1, val2):\n",
- " \"\"\"This is a longer docstring defining also the args and the return value. \n",
+ "def calcular_suma(val1, val2):\n",
+ " \"\"\"Esto es un docstring mas largo que tambien define los argumentos y el valor de retorno. \n",
"\n",
" Args:\n",
- " val1: The first parameter.\n",
- " val2: The second parameter.\n",
+ " val1: El primer parametro.\n",
+ " val2: El segundo parametro.\n",
"\n",
- " Returns:\n",
- " The sum of val1 and val2.\n",
+ " Devuelve:\n",
+ " La suma de val1 y val2.\n",
" \n",
" \"\"\"\n",
" return val1 + val2\n",
"\n",
- "print(help(calculate_sum))"
+ "print(help(calcular_suma))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### [`pass`](https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement) statement\n",
- "`pass` is a statement which does nothing when it's executed. It can be used e.g. a as placeholder to make the code syntatically correct while sketching the functions and/or classes of your application. For example, the following is valid Python. "
+ "### La palabra clave [`pass`](https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement)\n",
+ "`pass` es una declaracion que no hace nada cuando es ejecutada. Puede usarse para, por ej, como código provisorio para hacer que el código este sintaticamente correcto mientras pensamos como serán las funciones y/o clases de nuestro programa. Por ejemplo, lo siguiente es Python válido. "
]
},
{
@@ -222,10 +222,10 @@
"metadata": {},
"outputs": [],
"source": [
- "def my_function(some_argument):\n",
+ "def mi_funcion(algun_argumento):\n",
" pass\n",
"\n",
- "def my_other_function():\n",
+ "def mi_otra_funcion():\n",
" pass"
]
}
@@ -233,10 +233,10 @@
"metadata": {
"kernelspec": {
"display_name": "Python 3",
- "language": "python",
+ "languedad": "python",
"name": "python3"
},
- "language_info": {
+ "languedad_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
diff --git a/notebooks/beginner/notebooks/lists.ipynb b/notebooks/beginner/notebooks/lists.ipynb
index 0a08876..2dbf49c 100644
--- a/notebooks/beginner/notebooks/lists.ipynb
+++ b/notebooks/beginner/notebooks/lists.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# [Lists](https://docs.python.org/3/library/stdtypes.html#lists)"
+ "# [Listas](https://docs.python.org/3/library/stdtypes.html#Listas)"
]
},
{
@@ -13,8 +13,8 @@
"metadata": {},
"outputs": [],
"source": [
- "my_empty_list = []\n",
- "print('empty list: {}, type: {}'.format(my_empty_list, type(my_empty_list)))"
+ "mi_lista_vacia = []\n",
+ "print('lista vacia: {}, tipo: {}'.format(mi_lista_vacia, type(mi_lista_vacia)))"
]
},
{
@@ -23,16 +23,16 @@
"metadata": {},
"outputs": [],
"source": [
- "list_of_ints = [1, 2, 6, 7]\n",
- "list_of_misc = [0.2, 5, 'Python', 'is', 'still fun', '!']\n",
- "print('lengths: {} and {}'.format(len(list_of_ints), len(list_of_misc)))"
+ "lista_de_ints = [1, 2, 6, 7]\n",
+ "lista_mixta = [0.2, 5, 'Python', 'es', 'divertido', '!']\n",
+ "print('longitudes: {} y {}'.format(len(lista_de_ints), len(lista_mixta)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Accessing values"
+ "## Accediendo a valores"
]
},
{
@@ -41,9 +41,9 @@
"metadata": {},
"outputs": [],
"source": [
- "my_list = ['Python', 'is', 'still', 'cool']\n",
- "print(my_list[0])\n",
- "print(my_list[3])"
+ "mi_lista = ['Python', 'es', 'divertido', '(ponele)']\n",
+ "print(mi_lista[0])\n",
+ "print(mi_lista[3])"
]
},
{
@@ -52,16 +52,16 @@
"metadata": {},
"outputs": [],
"source": [
- "coordinates = [[12.0, 13.3], [0.6, 18.0], [88.0, 1.1]] # two dimensional\n",
- "print('first coordinate: {}'.format(coordinates[0]))\n",
- "print('second element of first coordinate: {}'.format(coordinates[0][1]))"
+ "coordenadas = [[12.0, 13.3], [0.6, 18.0], [88.0, 1.1]] # en dos dimensiones\n",
+ "print('primera coordenada: {}'.format(coordenadas[0]))\n",
+ "print('segundo elemento de la primera coordenada: {}'.format(coordenadas[0][1]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Updating values"
+ "## Actualizando valores"
]
},
{
@@ -70,20 +70,20 @@
"metadata": {},
"outputs": [],
"source": [
- "my_list = [0, 1, 2, 3, 4, 5]\n",
- "my_list[0] = 99\n",
- "print(my_list)\n",
+ "mi_lista = [0, 1, 2, 3, 4, 5]\n",
+ "mi_lista[0] = 99\n",
+ "print(mi_lista)\n",
"\n",
- "# remove first value\n",
- "del my_list[0]\n",
- "print(my_list)"
+ "# borro el primer valor\n",
+ "del mi_lista[0]\n",
+ "print(mi_lista)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Checking if certain value is present in list"
+ "## Me fijo si cierto valor está en la lista"
]
},
{
@@ -92,9 +92,9 @@
"metadata": {},
"outputs": [],
"source": [
- "languages = ['Java', 'C++', 'Go', 'Python', 'JavaScript']\n",
- "if 'Python' in languages:\n",
- " print('Python is there!')"
+ "lenguajes = ['Java', 'C++', 'Go', 'Python', 'JavaScript']\n",
+ "if 'Python' in lenguajes:\n",
+ " print('Python esta en la lista!')"
]
},
{
@@ -104,14 +104,14 @@
"outputs": [],
"source": [
"if 6 not in [1, 2, 3, 7]:\n",
- " print('number 6 is not present')"
+ " print('el numero 6 no esta presente')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## List are mutable"
+ "## Las listas son mutables"
]
},
{
@@ -121,16 +121,16 @@
"outputs": [],
"source": [
"original = [1, 2, 3]\n",
- "modified = original\n",
- "modified[0] = 99\n",
- "print('original: {}, modified: {}'.format(original, modified))"
+ "modificada = original\n",
+ "modificada[0] = 99\n",
+ "print('original: {}, modificada: {}'.format(original, modificada))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "You can get around this by creating new `list`:"
+ "Pueden solucionar esto creando una nueva `lista`:"
]
},
{
@@ -140,11 +140,11 @@
"outputs": [],
"source": [
"original = [1, 2, 3]\n",
- "modified = list(original) # Note list() \n",
- "# Alternatively, you can use copy method\n",
- "# modified = original.copy()\n",
- "modified[0] = 99\n",
- "print('original: {}, modified: {}'.format(original, modified))"
+ "modificada = list(original) # Noten list() \n",
+ "# De forma alternativa, pueden usar el metodo copy\n",
+ "# modificada = original.copy()\n",
+ "modificada[0] = 99\n",
+ "print('original: {}, modificada: {}'.format(original, modificada))"
]
},
{
@@ -160,9 +160,9 @@
"metadata": {},
"outputs": [],
"source": [
- "my_list = [1]\n",
- "my_list.append('ham')\n",
- "print(my_list)"
+ "mi_lista = [1]\n",
+ "mi_lista.append('jamon')\n",
+ "print(mi_lista)"
]
},
{
@@ -178,15 +178,15 @@
"metadata": {},
"outputs": [],
"source": [
- "my_list = ['Python', 'is', 'sometimes', 'fun']\n",
- "my_list.remove('sometimes')\n",
- "print(my_list)\n",
+ "mi_lista = ['Python', 'es', 'divertido', '(ponele)']\n",
+ "mi_lista.remove('divertido')\n",
+ "print(mi_lista)\n",
"\n",
- "# If you are not sure that the value is in list, better to check first:\n",
- "if 'Java' in my_list:\n",
- " my_list.remove('Java')\n",
+ "# Si no están seguros que el valor esté en la lista, mejor que se fijen primero:\n",
+ "if 'Java' in mi_lista:\n",
+ " mi_lista.remove('Java')\n",
"else:\n",
- " print('Java is not part of this story.')"
+ " print('Java no es parte de esta historia.')"
]
},
{
@@ -202,16 +202,16 @@
"metadata": {},
"outputs": [],
"source": [
- "numbers = [8, 1, 6, 5, 10]\n",
- "numbers.sort()\n",
- "print('numbers: {}'.format(numbers))\n",
+ "numeros = [8, 1, 6, 5, 10]\n",
+ "numeros.sort()\n",
+ "print('numeros: {}'.format(numeros))\n",
"\n",
- "numbers.sort(reverse=True)\n",
- "print('numbers reversed: {}'.format(numbers))\n",
+ "numeros.sort(reverse=True)\n",
+ "print('numeros invertidos: {}'.format(numeros))\n",
"\n",
- "words = ['this', 'is', 'a', 'list', 'of', 'words']\n",
- "words.sort()\n",
- "print('words: {}'.format(words))"
+ "palabras = ['esto', 'es', 'una', 'lista', 'de', 'palabras']\n",
+ "palabras.sort()\n",
+ "print('palabras: {}'.format(palabras))"
]
},
{
@@ -219,7 +219,7 @@
"metadata": {},
"source": [
"## `sorted(list)`\n",
- "While `list.sort()` sorts the list in-place, `sorted(list)` returns a new list and leaves the original untouched:"
+ "Mientras que `lista.sort()` ordena la lista original, `sorted(lista)` devuelve una nueva lista y deja la lista original sin tocar:"
]
},
{
@@ -228,9 +228,9 @@
"metadata": {},
"outputs": [],
"source": [
- "numbers = [8, 1, 6, 5, 10]\n",
- "sorted_numbers = sorted(numbers)\n",
- "print('numbers: {}, sorted: {}'.format(numbers, sorted_numbers))"
+ "numeros = [8, 1, 6, 5, 10]\n",
+ "numeros_ordenados = sorted(numeros)\n",
+ "print('numeros: {}, ordenados: {}'.format(numeros, numeros_ordenados))"
]
},
{
@@ -246,17 +246,17 @@
"metadata": {},
"outputs": [],
"source": [
- "first_list = ['beef', 'ham']\n",
- "second_list = ['potatoes',1 ,3]\n",
- "first_list.extend(second_list)\n",
- "print('first: {}, second: {}'.format(first_list, second_list))"
+ "primer_lista = ['churrasco', 'jamon']\n",
+ "segunda_lista = ['papas',1 ,3]\n",
+ "primer_lista.extend(segunda_lista)\n",
+ "print('primera: {}, segunda: {}'.format(primer_lista, segunda_lista))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Alternatively you can also extend lists by summing them:"
+ "También pueden extender listas sumandolas:"
]
},
{
@@ -265,14 +265,14 @@
"metadata": {},
"outputs": [],
"source": [
- "first = [1, 2, 3]\n",
- "second = [4, 5]\n",
- "first += second # same as: first = first + second\n",
- "print('first: {}'.format(first))\n",
+ "primera = [1, 2, 3]\n",
+ "segunda = [4, 5]\n",
+ "primera += segunda # lo mismo que: primera = primera + segunda\n",
+ "print('primera: {}'.format(primera))\n",
"\n",
- "# If you need a new list\n",
- "summed = first + second\n",
- "print('summed: {}'.format(summed))"
+ "# Si necesitan una lista nueva\n",
+ "sumada = primera + segunda\n",
+ "print('sumada: {}'.format(sumada))"
]
},
{
@@ -288,9 +288,9 @@
"metadata": {},
"outputs": [],
"source": [
- "my_list = ['a', 'b', 'ham']\n",
- "my_list.reverse()\n",
- "print(my_list)"
+ "mi_lista = ['a', 'b', 'jamon']\n",
+ "mi_lista.reverse()\n",
+ "print(mi_lista)"
]
}
],
diff --git a/notebooks/beginner/notebooks/numbers.ipynb b/notebooks/beginner/notebooks/numbers.ipynb
index 95f45c5..a6e2694 100644
--- a/notebooks/beginner/notebooks/numbers.ipynb
+++ b/notebooks/beginner/notebooks/numbers.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# [Numbers](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)"
+ "# [Números](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)"
]
},
{
@@ -22,8 +22,8 @@
},
"outputs": [],
"source": [
- "my_int = 6\n",
- "print('value: {}, type: {}'.format(my_int, type(my_int)))"
+ "mi_int = 6\n",
+ "print('valor: {}, tipo: {}'.format(mi_int, type(mi_int)))"
]
},
{
@@ -41,15 +41,15 @@
},
"outputs": [],
"source": [
- "my_float = float(my_int)\n",
- "print('value: {}, type: {}'.format(my_float, type(my_float)))"
+ "mi_float = float(mi_int)\n",
+ "print('valor: {}, tipo: {}'.format(mi_float, type(mi_float)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Note that division of `int`s produces `float`:"
+ "Noten que la división de `int`s producen `float`s:"
]
},
{
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Be aware of the binary floating-point pitfalls (see [Decimal](#decimal) for workaround):"
+ "Tengan cuidado con los calculos que involucren floats (vean [Decimal](#decimal) para una solución temporal):"
]
},
{
@@ -86,7 +86,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Floor division `//`, modulus `%`, power `**`"
+ "## División entera `//`, modulo `%`, potencia `**`"
]
},
{
@@ -143,9 +143,9 @@
},
"outputs": [],
"source": [
- "from_float = Decimal(0.1)\n",
- "from_str = Decimal('0.1')\n",
- "print('from float: {}\\nfrom string: {}'.format(from_float, from_str))"
+ "desde_float = Decimal(0.1)\n",
+ "desde_string = Decimal('0.1')\n",
+ "print('desde float: {}\\ndesde string: {}'.format(desde_float, desde_string))"
]
},
{
@@ -156,17 +156,17 @@
},
"outputs": [],
"source": [
- "my_decimal = Decimal('0.1')\n",
- "sum_of_decimals = my_decimal + my_decimal + my_decimal\n",
- "print(sum_of_decimals == Decimal('0.3'))"
+ "mi_decimal = Decimal('0.1')\n",
+ "suma_de_decimales = mi_decimal + mi_decimal + mi_decimal\n",
+ "print(suma_de_decimales == Decimal('0.3'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Operator precedence in calculations\n",
- "Mathematical operator precedence applies. Use brackets if you want to change the execution order:"
+ "## Orden de operadores en calculos\n",
+ "El orden matemático de los operadores afecta el calculo. Usen paréntesis si quieren cambiar el orden de ejecución:"
]
},
{
diff --git a/notebooks/beginner/notebooks/strings.ipynb b/notebooks/beginner/notebooks/strings.ipynb
index c87bba4..ed22d0b 100644
--- a/notebooks/beginner/notebooks/strings.ipynb
+++ b/notebooks/beginner/notebooks/strings.ipynb
@@ -13,7 +13,7 @@
"metadata": {},
"outputs": [],
"source": [
- "my_string = 'Python is my favorite programming language!'"
+ "mi_string = '¡Python es mi lenguaje de programación favorito!'"
]
},
{
@@ -22,7 +22,7 @@
"metadata": {},
"outputs": [],
"source": [
- "my_string"
+ "mi_string"
]
},
{
@@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
- "type(my_string)"
+ "type(mi_string)"
]
},
{
@@ -40,14 +40,14 @@
"metadata": {},
"outputs": [],
"source": [
- "len(my_string)"
+ "len(mi_string)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Respecting [PEP8](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) with long strings"
+ "### Los strings multilinea deberían tener como máximo 79 caracteres"
]
},
{
@@ -56,11 +56,11 @@
"metadata": {},
"outputs": [],
"source": [
- "long_story = ('Lorem ipsum dolor sit amet, consectetur adipiscing elit.' \n",
+ "historia_larga = ('Lorem ipsum dolor sit amet, consectetur adipiscing elit.' \n",
" 'Pellentesque eget tincidunt felis. Ut ac vestibulum est.' \n",
" 'In sed ipsum sit amet sapien scelerisque bibendum. Sed ' \n",
" 'sagittis purus eu diam fermentum pellentesque.')\n",
- "long_story"
+ "historia_larga"
]
},
{
@@ -74,7 +74,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "If you don't know how it works, you can always check the `help`:"
+ "Si no saben como funciona, siempre pueden fijarse la ayuda (`help`):"
]
},
{
@@ -90,7 +90,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "This will not modify `my_string` because replace is not done in-place."
+ "Esto no va a modificar `mi_string` porque `replace` no reemplaza el valor de la variable."
]
},
{
@@ -99,15 +99,15 @@
"metadata": {},
"outputs": [],
"source": [
- "my_string.replace('a', '?')\n",
- "print(my_string)"
+ "mi_string.replace('a', '?')\n",
+ "print(mi_string)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "You have to store the return value of `replace` instead."
+ "Para hacer eso tienen que guardar el valor devuelto por `replace`."
]
},
{
@@ -116,8 +116,8 @@
"metadata": {},
"outputs": [],
"source": [
- "my_modified_string = my_string.replace('is', 'will be')\n",
- "print(my_modified_string)"
+ "mi_string_modificado = mi_string.replace('es', 'va a ser')\n",
+ "print(mi_string_modificado)"
]
},
{
@@ -133,8 +133,8 @@
"metadata": {},
"outputs": [],
"source": [
- "secret = '{} is cool'.format('Python')\n",
- "print(secret)"
+ "secreto = '{} es genial'.format('Python')\n",
+ "print(secreto)"
]
},
{
@@ -143,9 +143,9 @@
"metadata": {},
"outputs": [],
"source": [
- "print('My name is {} {}, you can call me {}.'.format('John', 'Doe', 'John'))\n",
- "# is the same as:\n",
- "print('My name is {first} {family}, you can call me {first}.'.format(first='John', family='Doe'))"
+ "print('Mi nombre es {} {}, pero pueden llamarme {}.'.format('John', 'Doe', 'John'))\n",
+ "# es lo mismo que:\n",
+ "print('Mi nombre es {primer} {apellido}, pero pueden llamarme {primer}.'.format(primer='John', apellido='Doe'))"
]
},
{
@@ -164,7 +164,7 @@
"pandas = 'pandas'\n",
"numpy = 'numpy'\n",
"requests = 'requests'\n",
- "cool_python_libs = ', '.join([pandas, numpy, requests])"
+ "librerias_python = ', '.join([pandas, numpy, requests])"
]
},
{
@@ -173,14 +173,14 @@
"metadata": {},
"outputs": [],
"source": [
- "print('Some cool python libraries: {}'.format(cool_python_libs))"
+ "print('Algunas librerías piolas de Python: {}'.format(librerias_python))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Alternatives (not as [Pythonic](http://docs.python-guide.org/en/latest/writing/style/#idioms) and [slower](https://waymoot.org/home/python_string/)):"
+ "Otras formas de hacer lo mismo (pero más lento y peor):"
]
},
{
@@ -189,13 +189,13 @@
"metadata": {},
"outputs": [],
"source": [
- "cool_python_libs = pandas + ', ' + numpy + ', ' + requests\n",
- "print('Some cool python libraries: {}'.format(cool_python_libs))\n",
+ "librerias_python = pandas + ', ' + numpy + ', ' + requests\n",
+ "print('Algunas librerías piolas de Python: {}'.format(librerias_python))\n",
"\n",
- "cool_python_libs = pandas\n",
- "cool_python_libs += ', ' + numpy\n",
- "cool_python_libs += ', ' + requests\n",
- "print('Some cool python libraries: {}'.format(cool_python_libs))"
+ "librerias_python = pandas\n",
+ "librerias_python += ', ' + numpy\n",
+ "librerias_python += ', ' + requests\n",
+ "print('Algunas librerías piolas de Python: {}'.format(librerias_python))"
]
},
{
@@ -211,7 +211,7 @@
"metadata": {},
"outputs": [],
"source": [
- "mixed_case = 'PyTHoN hackER'"
+ "mezcla_mayus_minus = 'hackER dE PyTHoN'"
]
},
{
@@ -220,7 +220,7 @@
"metadata": {},
"outputs": [],
"source": [
- "mixed_case.upper()"
+ "mezcla_mayus_minus.upper()"
]
},
{
@@ -229,7 +229,7 @@
"metadata": {},
"outputs": [],
"source": [
- "mixed_case.lower()"
+ "mezcla_mayus_minus.lower()"
]
},
{
@@ -238,7 +238,7 @@
"metadata": {},
"outputs": [],
"source": [
- "mixed_case.title()"
+ "mezcla_mayus_minus.title()"
]
},
{
@@ -254,11 +254,11 @@
"metadata": {},
"outputs": [],
"source": [
- "ugly_formatted = ' \\n \\t Some story to tell '\n",
- "stripped = ugly_formatted.strip()\n",
+ "formateo_feo = ' \\n \\t Una historia para contar '\n",
+ "desnudo = formateo_feo.strip()\n",
"\n",
- "print('ugly: {}'.format(ugly_formatted))\n",
- "print('stripped: {}'.format(ugly_formatted.strip()))"
+ "print('feo: {}'.format(formateo_feo))\n",
+ "print('desnudo: {}'.format(formateo_feo.strip()))"
]
},
{
@@ -274,9 +274,9 @@
"metadata": {},
"outputs": [],
"source": [
- "sentence = 'three different words'\n",
- "words = sentence.split()\n",
- "print(words)"
+ "oracion = 'tres palabras diferentes'\n",
+ "palabras = oracion.split()\n",
+ "print(palabras)"
]
},
{
@@ -285,7 +285,7 @@
"metadata": {},
"outputs": [],
"source": [
- "type(words)"
+ "type(palabras)"
]
},
{
@@ -294,16 +294,16 @@
"metadata": {},
"outputs": [],
"source": [
- "secret_binary_data = '01001,101101,11100000'\n",
- "binaries = secret_binary_data.split(',')\n",
- "print(binaries)"
+ "dato_binario_secreto = '01001,101101,11100000'\n",
+ "binario = dato_binario_secreto.split(',')\n",
+ "print(binario)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Calling multiple methods in a row"
+ "## Llamando a varios metodos a la vez"
]
},
{
@@ -312,16 +312,16 @@
"metadata": {},
"outputs": [],
"source": [
- "ugly_mixed_case = ' ThIS LooKs BAd '\n",
- "pretty = ugly_mixed_case.strip().lower().replace('bad', 'good')\n",
- "print(pretty)"
+ "fea_mezcla_mayus_minus = ' EsTo sE Ve MaL '\n",
+ "lindo = fea_mezcla_mayus_minus.strip().lower().replace('mal', 'bien')\n",
+ "print(lindo)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Note that execution order is from left to right. Thus, this won't work:"
+ "Noten que el orden de ejecución es de izquierda a derecha. Por lo que esto no va a funcionar:"
]
},
{
@@ -330,15 +330,15 @@
"metadata": {},
"outputs": [],
"source": [
- "pretty = ugly_mixed_case.replace('bad', 'good').strip().lower()\n",
- "print(pretty)"
+ "lindo = fea_mezcla_mayus_minus.replace('mal', 'bien').strip().lower()\n",
+ "print(lindo)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## [Escape characters](http://python-reference.readthedocs.io/en/latest/docs/str/escapes.html#escape-characters)"
+ "## [Escapar caracteres](http://python-reference.readthedocs.io/en/latest/docs/str/escapes.html#escape-characters)"
]
},
{
@@ -347,8 +347,8 @@
"metadata": {},
"outputs": [],
"source": [
- "two_lines = 'First line\\nSecond line'\n",
- "print(two_lines)"
+ "dos_lineas = 'Primera linea\\nSegunda linea'\n",
+ "print(dos_lineas)"
]
},
{
@@ -357,8 +357,8 @@
"metadata": {},
"outputs": [],
"source": [
- "indented = '\\tThis will be indented'\n",
- "print(indented)"
+ "indentado = '\\tEsto va a ser indentado'\n",
+ "print(indentado)"
]
}
],
diff --git a/notebooks/p5/data/dibujito.jpg b/notebooks/p5/data/dibujito.jpg
new file mode 100644
index 0000000..46dbc4e
Binary files /dev/null and b/notebooks/p5/data/dibujito.jpg differ
diff --git a/notebooks/p5/data/drawing-01.png b/notebooks/p5/data/drawing-01.png
new file mode 100644
index 0000000..5fd587b
Binary files /dev/null and b/notebooks/p5/data/drawing-01.png differ
diff --git a/notebooks/p5/data/drawing-01.svg b/notebooks/p5/data/drawing-01.svg
new file mode 100644
index 0000000..442c55b
--- /dev/null
+++ b/notebooks/p5/data/drawing-01.svg
@@ -0,0 +1,109 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-03.png b/notebooks/p5/data/drawing-03.png
new file mode 100644
index 0000000..e4d5e95
Binary files /dev/null and b/notebooks/p5/data/drawing-03.png differ
diff --git a/notebooks/p5/data/drawing-03.svg b/notebooks/p5/data/drawing-03.svg
new file mode 100644
index 0000000..e32593e
--- /dev/null
+++ b/notebooks/p5/data/drawing-03.svg
@@ -0,0 +1,172 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-04.png b/notebooks/p5/data/drawing-04.png
new file mode 100644
index 0000000..ab6ec14
Binary files /dev/null and b/notebooks/p5/data/drawing-04.png differ
diff --git a/notebooks/p5/data/drawing-04.svg b/notebooks/p5/data/drawing-04.svg
new file mode 100644
index 0000000..5b983f4
--- /dev/null
+++ b/notebooks/p5/data/drawing-04.svg
@@ -0,0 +1,50 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-05.png b/notebooks/p5/data/drawing-05.png
new file mode 100644
index 0000000..091f000
Binary files /dev/null and b/notebooks/p5/data/drawing-05.png differ
diff --git a/notebooks/p5/data/drawing-05.svg b/notebooks/p5/data/drawing-05.svg
new file mode 100644
index 0000000..963e0e7
--- /dev/null
+++ b/notebooks/p5/data/drawing-05.svg
@@ -0,0 +1,116 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-06.png b/notebooks/p5/data/drawing-06.png
new file mode 100644
index 0000000..375af12
Binary files /dev/null and b/notebooks/p5/data/drawing-06.png differ
diff --git a/notebooks/p5/data/drawing-06.svg b/notebooks/p5/data/drawing-06.svg
new file mode 100644
index 0000000..31823f7
--- /dev/null
+++ b/notebooks/p5/data/drawing-06.svg
@@ -0,0 +1,166 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-07.png b/notebooks/p5/data/drawing-07.png
new file mode 100644
index 0000000..5cd82c9
Binary files /dev/null and b/notebooks/p5/data/drawing-07.png differ
diff --git a/notebooks/p5/data/drawing-07.svg b/notebooks/p5/data/drawing-07.svg
new file mode 100644
index 0000000..fb53aaf
--- /dev/null
+++ b/notebooks/p5/data/drawing-07.svg
@@ -0,0 +1,170 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-08.png b/notebooks/p5/data/drawing-08.png
new file mode 100644
index 0000000..7235d48
Binary files /dev/null and b/notebooks/p5/data/drawing-08.png differ
diff --git a/notebooks/p5/data/drawing-08.svg b/notebooks/p5/data/drawing-08.svg
new file mode 100644
index 0000000..6d1bb4b
--- /dev/null
+++ b/notebooks/p5/data/drawing-08.svg
@@ -0,0 +1,149 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-09.png b/notebooks/p5/data/drawing-09.png
new file mode 100644
index 0000000..0ebbdcd
Binary files /dev/null and b/notebooks/p5/data/drawing-09.png differ
diff --git a/notebooks/p5/data/drawing-09.svg b/notebooks/p5/data/drawing-09.svg
new file mode 100644
index 0000000..75508be
--- /dev/null
+++ b/notebooks/p5/data/drawing-09.svg
@@ -0,0 +1,160 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-10.png b/notebooks/p5/data/drawing-10.png
new file mode 100644
index 0000000..26d3524
Binary files /dev/null and b/notebooks/p5/data/drawing-10.png differ
diff --git a/notebooks/p5/data/drawing-10.svg b/notebooks/p5/data/drawing-10.svg
new file mode 100644
index 0000000..b4efcda
--- /dev/null
+++ b/notebooks/p5/data/drawing-10.svg
@@ -0,0 +1,164 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-11.png b/notebooks/p5/data/drawing-11.png
new file mode 100644
index 0000000..ab2be57
Binary files /dev/null and b/notebooks/p5/data/drawing-11.png differ
diff --git a/notebooks/p5/data/drawing-11.svg b/notebooks/p5/data/drawing-11.svg
new file mode 100644
index 0000000..299a71b
--- /dev/null
+++ b/notebooks/p5/data/drawing-11.svg
@@ -0,0 +1,164 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/drawing-12.png b/notebooks/p5/data/drawing-12.png
new file mode 100644
index 0000000..e08816c
Binary files /dev/null and b/notebooks/p5/data/drawing-12.png differ
diff --git a/notebooks/p5/data/drawing-12.svg b/notebooks/p5/data/drawing-12.svg
new file mode 100644
index 0000000..68c08c7
--- /dev/null
+++ b/notebooks/p5/data/drawing-12.svg
@@ -0,0 +1,169 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/data/grayscale.svg b/notebooks/p5/data/grayscale.svg
new file mode 100644
index 0000000..1f95aa3
--- /dev/null
+++ b/notebooks/p5/data/grayscale.svg
@@ -0,0 +1,23 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/color.ipynb b/notebooks/p5/notebooks/color.ipynb
new file mode 100644
index 0000000..7ab2bb6
--- /dev/null
+++ b/notebooks/p5/notebooks/color.ipynb
@@ -0,0 +1,256 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# [Color](https://p5.readthedocs.io/en/latest/tutorials/color.html)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Color\n",
+ "En el mundo digital, cuando queremos hablar de un color, se requiere de precisión. Decir 'Che, podes hacer que ese circulo sea azul verdoso?' no va a ser suficiente. En vez de eso, el color es definido como un rango de numeros. Vamos a empezar con el caso más simple: blanco y negro, o escala de grises. `0` significa negro, `255` significa blanco. Entre esos dos, cualquier otro numero - 50, 87, 162, 209, etc - es un tono de gris yendo desde el negro al blanco.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Nota sobre el color y su representación digital\n",
+ "El color para una determinada figura necesita ser almacenado en la memoria de la computadora. Esta memoria es solo una secuencia larga de 0s y 1s (una bocha de interruptores encendidos y apagados). Cada uno de estos interruptores es un bit, ocho de ellos juntos es un byte. Imaginen si tuvieramos ocho bits (un byte) en una secuencia - ¿cuantas maneras hay de configurar esos interruptores? La respuesta es 256 posibilidades, o el rango desde el 0 al 255. Vamos a usar color de ocho bits para nuestra escala de grises y 24 bits para color completo (ocho bits para el rojo, verde, y azul).\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Añadiendo las funciones `p5.stroke()` y `p5.fill()` antes de que algo se dibuje, podemos establecer el color de cualquier figura. También tenemos la función `p5.background()` que nos establece el color de fondo para la ventana. Acá hay un ejemplo:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def draw():\n",
+ " background(255)\n",
+ " stroke(0)\n",
+ " fill(150)\n",
+ " rect((50, 50), 75, 100)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "El trazo o el relleno pueden ser eliminados con las funciones: `p5.no_stroke()` y `p5.no_fill()`. Nuestro instinto nos podría decir que `stroke(0)` sirve para no tener trazo, sin embargo, es importante recordar que 0 no es 'nada', sino que simboliza el color negro. También, recuerden no eliminar ambos - con `no_stroke` y `no_fill`, porque no va a aparecer nada!\n",
+ "Vale destacar que, si dibujamos dos figuras, p5 va a usar el trazo y relleno que se especifico por última vez, leyendo el código de arriba para abajo.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Color RGB\n",
+ "Recuerdan cuando pintaban con los dedos? Mezclando los tres colores 'primarios', podíamos obtener cualquier color. Mezclar todos los colores al mismo tiempo terminaba siendo un marrón medio raro. Mientras más pintura añadías, más oscuro se ponía. Los colores digitales también son construidos mezclando los tres colores primarios, pero funcionan diferente que la pintura. Primero, los primarios son diferentes: rojo, verde y azul (de ahí 'RGB'). Y con el color en la pantalla, están mezclando luz, no pintura, así que las reglas son diferentes también.\n",
+ "\n",
+ "\n",
+ "* Rojo + Verde = Amarillo\n",
+ "* Rojo + Azul = Purpura\n",
+ "* Verde + Azul = Cian (azul verdoso)\n",
+ "* Rojo + Verde + Azul = Blanco\n",
+ "* Ningún color = Negro"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Esto asume que los colores son tan brillantes como se pueda, pero obviamente tenemos un rango de color disponible, por ejemplo un poco de rojo más un poco de verde más un poco de azul nos da gris, y un poco de rojo más un poco de azul nos da purpura oscuro. Puede que nos cueste acostumbrarnos, pero mientras más programemos y experimentemos con color RGB, más intuitivo será, al igual de como era cuando lo haciamos con nuestros dedos. Y por supuesto no podemos decir 'mezclame un toque de rojo con un poquito de azul', sino que van a tener que indicar la cantidad exacta.\n",
+ "En cuanto a la escala de grises, el color individual del elemento son expresados como rangos desde el 0 (nada de ese color) hasta el 255 (lo más posible), y están listados en orden R, G, y B.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ " def draw():\n",
+ " background(255)\n",
+ " no_stroke()\n",
+ "\n",
+ " # bright red\n",
+ " fill(255, 0, 0)\n",
+ " circle((72, 72), 58)\n",
+ "\n",
+ " # dark red\n",
+ " fill(127, 0, 0)\n",
+ " circle((144, 72), 58)\n",
+ "\n",
+ " # Pink (pale red)\n",
+ " fill(255, 200, 200)\n",
+ " circle((216, 72), 58)\n",
+ "\n",
+ " if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Transparencia de colores\n",
+ "Además de los componentes rojo, verde y azul de cada color, tenemos un cuarto componente adicional y opcional, al que nos referimos como el 'alpha' del color. Alpha significa transparencia y es particularmente útil cuando querramos dibujar dos elementos o más elementos, uno arriba del otro, y que se pueda ver a través de ellos (translúcidos). También se les dice 'canal alpha' a los valores alpha de una imagen.\n",
+ "\n",
+ "Es importante darnos cuenta que los pixeles no son literalmente transparentes, sino que es una simple ilusión optica que se aplica mezclando colores. Atrás de escena, Processing toma el número del color y añade un porcentaje de uno al porcentaje de otro, haciendo que lo percibamos como 'transparente'.\n",
+ "Los valores Alpha van del 0 al 255, donde 0 es totalmente transparente (0% opaco) y 255 complementamente opaco (100% opaco).\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(200, 200)\n",
+ " no_stroke()\n",
+ "\n",
+ "def draw():\n",
+ " background(0)\n",
+ "\n",
+ " # Si no hay cuarto argumento, significa 100% opaco.\n",
+ " fill(0, 0, 255)\n",
+ " rect((0, 0), 100, 200)\n",
+ "\n",
+ " # 255 significa 100% opaco.\n",
+ " fill(255, 0, 0, 255)\n",
+ " rect((0, 0), 200, 40)\n",
+ "\n",
+ " # 75% opaco.\n",
+ " fill(255, 0, 0, 191)\n",
+ " rect((0, 50), 200, 40)\n",
+ "\n",
+ " # 55% opaco.\n",
+ " fill(255, 0, 0, 127)\n",
+ " rect((0, 100), 200, 40)\n",
+ "\n",
+ " # 25% opaco.\n",
+ " fill(255, 0, 0, 63)\n",
+ " rect((0, 150), 200, 40)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Rangos de color personalizados\n",
+ "Los colores RGB con rangos del 0 al 255 no son la única forma de manejar colores en Processing. Atrás de escena en la memoria de la computadora, el color es hablado como una serie de 24 bits (o 32 en el caso de colores con un alpha). Sin embargo, Processing nos deja pensar los colores de cualquier forma que nos plazca, y traduce nuestros valores a numeros que la computadora entiende. Por ejemplo, capaz prefieren pensar el color como un rango del 0 al 100 (como un porcentaje). Pueden hacer eso usando el modo personalizado `p5.color_mode()`.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "color_mode('RGB', 100)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "La función de arriba dice: 'OK, quiero pensar los colores en terminos de rojo, verde y azul. El rango de los valores van a ser del 0 al 100'.\n",
+ "\n",
+ "Aunque rara vez es conveniente hacerlo, también podemos tener diferentes rangos para cada componente de color:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "color_mode('RGB', 100, 500, 10, 255)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Ahora estamos diciendo 'Los valores del rojo van del 0 al 100, los del verde del 0 al 500, los del azul del 0 al 10 y los del alpha del 0 al 255'.\n",
+ "\n",
+ "Finalmente, aunque probablemente solo necesiten el color RGB para sus necesidades de programación, pueden también especificar colores en el modo HSB (tono, saturación y brillo). Sin ir muy en detalle, así funciona el color HSB:\n",
+ "\n",
+ "\n",
+ "* Hue (tono) - El tipo de color, va del 0 al 255 por defecto.\n",
+ "* Saturation (saturación) - La viveza del color, va del 0 al 255 por defecto.\n",
+ "* Brightness (brillo) - El, bueno, brillo del color, va del 0 al 255 por defecto.\n",
+ "\n",
+ "Con `p5.color_mode()` pueden establecer sus propios rangos para estos valores. Algunos prefieren el rango 0-360 para el tono (como un circulo) y 0-100 para la saturación y el brillo (como 0-100%).\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "languedad": "python",
+ "name": "python3"
+ },
+ "languedad_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/p5/notebooks/coordenadas.ipynb b/notebooks/p5/notebooks/coordenadas.ipynb
new file mode 100644
index 0000000..bf68c91
--- /dev/null
+++ b/notebooks/p5/notebooks/coordenadas.ipynb
@@ -0,0 +1,165 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# [Sistema de coordenadas y figuras](https://p5.readthedocs.io/en/latest/tutorials/coordinate%20system%20and%20shapes.html)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Sistema de coordenadas y figuras\n",
+ "Antes de que empecemos a programar con Processing, primero debemos comunicarnos con nuestro ser de primaria, sacar una hoja cuadriculada, y dibujar una linea. La distancia mas corta entre dos puntos es una linea ni más ni menos, y es donde vamos a empezar, con dos puntos en la hoja cuadriculada.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "La imagen de arriba muestra una linea entre el punto A (1,0) y el punto B (4,5). Si quisieran guiar a un amigo suyo para que dibuje la misma linea, les gritarias 'dibuja una linea desde el punto uno-cero hasta el punto cuatro-cinco, porfa.'\n",
+ "Bueno, por el momento, imaginense que su amigo es una computadora y que quieren guiar a este amiguito digital a que muestre la misma linea en su pantalla. El mismo comando vale (solo esta vez podemos evitar las cordialidades e ir directo al grano). Así sería la forma de hacerlo:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "line((1,0),(4,5))\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Incluso sin haber estudiado mucho la sintaxis de nuestro lenguaje, el código de arriba debería tener bastante sentido para cualquiera. Le estamos dando un comando (una función) a la maquinita que se llama 'line'. Además, le estamos dando algunos argumentos sobre la forma en la que debería ser dibujada esa linea, desde el punto A al punto B. Si lo pensaramos como una oración, la función es un verbo y los argumentos son los objetos de la oración.\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "La idea sería darnos cuenta que la pantalla de la computadora no es más que una hoja cuadriculada cheta. Cada pixel de la pantalla es una coordenada - dos numeros, uno 'x' (horizontal) y otro 'y' (vertical) - que determina el lugar de un punto en el espacio. Y es nuestro trabajo especificar que figuras y colores van a aparecer en esas coordenadas.\n",
+ "Sin embargo, hay una trampa. El sistema de coordenadas que nos enseñaron en la escuela (sistema cartesiano) ubica al (0,0) en el centro del eje y apuntando para arriba y el eje x apuntando a la derecha (en la dirección positiva, en la negativa para abajo y para la izquierda). El sistema de coordenadas para los pixeles de una pantalla de computadora, sin embargo, están al revés en el eje y. El (0,0) se puede encontrar arriba a la izquierda con la dirección positiva a la derecha horizontalmente y abajo verticalmente.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Figuras simples\n",
+ "La mayoria de los ejemplos de programación que van a ver con Processing son visuales por naturaleza. Estos ejemplos, en su núcleo, involucran dibujar figuras y establecer pixeles. Vamos a empezar viendo las cuatro figuras primitivas.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Por cada figura, vamos a preguntarnos que información es requerida para especificar la ubicación y tamaño (y después color) de esa figura y aprenderemos como Processing espera recibir esa información. En los diagramas de abajo, vamos a asumir que el tamaño de nuestra ventana va a ser de 10 pixeles de alto por 10 pixeles de ancho. Esto no es particularmente realista ya que cuando empecemos a programar probablemente vamos a trabajar con ventanas mucho más grandes (10x10 pixeles son apenas unos milimitros del tamaño de la pantalla). Sin embargo, para propositos demostrativos, es bueno trabajar con numeros chicos para ilustrar mejor y de forma más sencilla.\n",
+ "Un `point()` es la figura más sencilla de todas y un buen lugar donde empezar. Para dibujar un punto, solo necesitamos unas coordenadas x e y.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Una `line()` no es terriblemente dificil tampoco y solo requiere dos puntos: (x1,y1) y (x2,y2):\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Una vez que llegamos al dibujar los `rect()`, las cosas se complican un poco. En Processing, un rectangulo es descripto por las coordenadas para su esquina superior izquierda, además de su ancho y altura.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Una segunda manera de dibujar un rectangulo involucra especificar el punto medio, además de su ancho y altura. Si preferimos este metodo, primero debemos indicar que queremos usar el modo 'CENTER' antes de usar la función para el rectángulo en sí. Ojo que Processing es sensible a las mayusculas, igual que Python.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Finalmente, podemos dibujar un rectángulo con dos puntos (uno para la esquina superior izquierda y uno para la esquina inferior derecha). El modo acá es 'CORNERS'.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Una vez que estemos mas comodos con el concepto de dibujar un rectangulo, dibujar un `ellipse()` es facilisimo. De hecho, es identico a `rect()` la diferencia siendo que un elipse es dibujado donde los limites del rectangulo estarían. El modo por defecto para ellipse() es 'CENTER', en vez de 'CORNER'.\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Es importante destacar que estos elipses no se ven particularmente circulares. Processing tiene una metodologia integrada para seleccionar que pixeles deberían ser usados para crear una forma circular. Con el zoom al mango como está aca, obtenemos un puñado de cuadrados en un patrón quasi-circular, pero sin zoom, tendremos un lindo elipse redondo. Processing también nos da el poder de desarrollar nuestros propios algoritmos para colorear pixeles individuales (de hecho, ya podemos imaginar como podríamos hacer esto usando `point` una y otra vez), pero por ahora, nos quedamos satisfechos con dejar que `ellipse` haga todo el laburo.\n",
+ "Ahora veamos lo que un poco de código con figuras puede lograr en un ambiente mas realista, con una ventana de 200x200. Noten el uso de la función `size()` para especificar el ancho y alto de la ventana.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "size(200,200)\n",
+ "rectMode('CENTER')\n",
+ "rect((100,100),20,100)\n",
+ "ellipse((100,70),60,60)\n",
+ "ellipse((81,70),16,32)\n",
+ "ellipse((119,70),16,32)\n",
+ "line((90,150),(80,160))\n",
+ "line((110,150),(120,160))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "languedad": "python",
+ "name": "python3"
+ },
+ "languedad_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/p5/notebooks/imagenes/07_01_1.png b/notebooks/p5/notebooks/imagenes/07_01_1.png
new file mode 100644
index 0000000..0573489
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_01_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_03_1.png b/notebooks/p5/notebooks/imagenes/07_03_1.png
new file mode 100644
index 0000000..f119fd4
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_03_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_03_2.png b/notebooks/p5/notebooks/imagenes/07_03_2.png
new file mode 100644
index 0000000..6020086
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_03_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_04_1.png b/notebooks/p5/notebooks/imagenes/07_04_1.png
new file mode 100644
index 0000000..1b390f3
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_04_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_04_2.png b/notebooks/p5/notebooks/imagenes/07_04_2.png
new file mode 100644
index 0000000..d480770
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_04_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_05_1.png b/notebooks/p5/notebooks/imagenes/07_05_1.png
new file mode 100644
index 0000000..e3af8d8
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_05_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_05_2.png b/notebooks/p5/notebooks/imagenes/07_05_2.png
new file mode 100644
index 0000000..316173b
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_05_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_07_1.png b/notebooks/p5/notebooks/imagenes/07_07_1.png
new file mode 100644
index 0000000..06b870b
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_07_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_07_2.png b/notebooks/p5/notebooks/imagenes/07_07_2.png
new file mode 100644
index 0000000..6407e07
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_07_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_08_1.png b/notebooks/p5/notebooks/imagenes/07_08_1.png
new file mode 100644
index 0000000..9e7efab
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_08_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_08_2.png b/notebooks/p5/notebooks/imagenes/07_08_2.png
new file mode 100644
index 0000000..28a2677
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_08_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_09_1.png b/notebooks/p5/notebooks/imagenes/07_09_1.png
new file mode 100644
index 0000000..28618d8
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_09_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_09_2.png b/notebooks/p5/notebooks/imagenes/07_09_2.png
new file mode 100644
index 0000000..e07a1a8
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_09_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_09_3.png b/notebooks/p5/notebooks/imagenes/07_09_3.png
new file mode 100644
index 0000000..36b4ab2
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_09_3.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_10_1.png b/notebooks/p5/notebooks/imagenes/07_10_1.png
new file mode 100644
index 0000000..06c4d3e
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_10_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_10_2.png b/notebooks/p5/notebooks/imagenes/07_10_2.png
new file mode 100644
index 0000000..9100268
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_10_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_11_1.png b/notebooks/p5/notebooks/imagenes/07_11_1.png
new file mode 100644
index 0000000..d81b4b2
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_11_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_11_2.png b/notebooks/p5/notebooks/imagenes/07_11_2.png
new file mode 100644
index 0000000..445e653
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_11_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_12_1.png b/notebooks/p5/notebooks/imagenes/07_12_1.png
new file mode 100644
index 0000000..60c0c42
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_12_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_12_2.png b/notebooks/p5/notebooks/imagenes/07_12_2.png
new file mode 100644
index 0000000..ac7501a
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_12_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_13_1.png b/notebooks/p5/notebooks/imagenes/07_13_1.png
new file mode 100644
index 0000000..c93d072
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_13_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_13_2tif.png b/notebooks/p5/notebooks/imagenes/07_13_2tif.png
new file mode 100644
index 0000000..200e9a3
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_13_2tif.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_13_3.png b/notebooks/p5/notebooks/imagenes/07_13_3.png
new file mode 100644
index 0000000..499291d
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_13_3.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_14_1.png b/notebooks/p5/notebooks/imagenes/07_14_1.png
new file mode 100644
index 0000000..f4595b8
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_14_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_14_2.png b/notebooks/p5/notebooks/imagenes/07_14_2.png
new file mode 100644
index 0000000..6cc9117
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_14_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_14_3.png b/notebooks/p5/notebooks/imagenes/07_14_3.png
new file mode 100644
index 0000000..742dbcd
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_14_3.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_15_1.png b/notebooks/p5/notebooks/imagenes/07_15_1.png
new file mode 100644
index 0000000..5d1eb12
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_15_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_15_2.png b/notebooks/p5/notebooks/imagenes/07_15_2.png
new file mode 100644
index 0000000..700dbda
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_15_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_16_1.png b/notebooks/p5/notebooks/imagenes/07_16_1.png
new file mode 100644
index 0000000..989ea3a
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_16_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_16_2.png b/notebooks/p5/notebooks/imagenes/07_16_2.png
new file mode 100644
index 0000000..b46a13e
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_16_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_17_1.png b/notebooks/p5/notebooks/imagenes/07_17_1.png
new file mode 100644
index 0000000..5b8d09f
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_17_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_18_1.png b/notebooks/p5/notebooks/imagenes/07_18_1.png
new file mode 100644
index 0000000..4a9fd33
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_18_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_18_2.png b/notebooks/p5/notebooks/imagenes/07_18_2.png
new file mode 100644
index 0000000..738132b
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_18_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_21_1.png b/notebooks/p5/notebooks/imagenes/07_21_1.png
new file mode 100644
index 0000000..102ef89
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_21_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_21_2.png b/notebooks/p5/notebooks/imagenes/07_21_2.png
new file mode 100644
index 0000000..87635ce
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_21_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_21_3.png b/notebooks/p5/notebooks/imagenes/07_21_3.png
new file mode 100644
index 0000000..9042365
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_21_3.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_22_1.png b/notebooks/p5/notebooks/imagenes/07_22_1.png
new file mode 100644
index 0000000..483aaac
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_22_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_22_2.png b/notebooks/p5/notebooks/imagenes/07_22_2.png
new file mode 100644
index 0000000..ce286e2
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_22_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_23_1.png b/notebooks/p5/notebooks/imagenes/07_23_1.png
new file mode 100644
index 0000000..f7e4a3d
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_23_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_23_2.png b/notebooks/p5/notebooks/imagenes/07_23_2.png
new file mode 100644
index 0000000..e442271
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_23_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_24_1.png b/notebooks/p5/notebooks/imagenes/07_24_1.png
new file mode 100644
index 0000000..cc1d7fe
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_24_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_24_2.png b/notebooks/p5/notebooks/imagenes/07_24_2.png
new file mode 100644
index 0000000..769045c
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_24_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_25_1.png b/notebooks/p5/notebooks/imagenes/07_25_1.png
new file mode 100644
index 0000000..fca7ce0
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_25_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_25_2.png b/notebooks/p5/notebooks/imagenes/07_25_2.png
new file mode 100644
index 0000000..fb0fca8
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_25_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_25_3.png b/notebooks/p5/notebooks/imagenes/07_25_3.png
new file mode 100644
index 0000000..737493e
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_25_3.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_26_1.png b/notebooks/p5/notebooks/imagenes/07_26_1.png
new file mode 100644
index 0000000..54e78ac
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_26_1.png differ
diff --git a/notebooks/p5/notebooks/imagenes/07_26_2.png b/notebooks/p5/notebooks/imagenes/07_26_2.png
new file mode 100644
index 0000000..cf84934
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/07_26_2.png differ
diff --git a/notebooks/p5/notebooks/imagenes/background-beispiel.png b/notebooks/p5/notebooks/imagenes/background-beispiel.png
new file mode 100644
index 0000000..2b972c9
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/background-beispiel.png differ
diff --git a/notebooks/p5/notebooks/imagenes/dibujito.jpg b/notebooks/p5/notebooks/imagenes/dibujito.jpg
new file mode 100644
index 0000000..46dbc4e
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/dibujito.jpg differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-01.png b/notebooks/p5/notebooks/imagenes/drawing-01.png
new file mode 100644
index 0000000..5fd587b
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-01.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-01.svg b/notebooks/p5/notebooks/imagenes/drawing-01.svg
new file mode 100644
index 0000000..442c55b
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-01.svg
@@ -0,0 +1,109 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-03.png b/notebooks/p5/notebooks/imagenes/drawing-03.png
new file mode 100644
index 0000000..e4d5e95
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-03.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-03.svg b/notebooks/p5/notebooks/imagenes/drawing-03.svg
new file mode 100644
index 0000000..e32593e
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-03.svg
@@ -0,0 +1,172 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-04.png b/notebooks/p5/notebooks/imagenes/drawing-04.png
new file mode 100644
index 0000000..ab6ec14
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-04.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-04.svg b/notebooks/p5/notebooks/imagenes/drawing-04.svg
new file mode 100644
index 0000000..5b983f4
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-04.svg
@@ -0,0 +1,50 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-05.png b/notebooks/p5/notebooks/imagenes/drawing-05.png
new file mode 100644
index 0000000..091f000
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-05.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-05.svg b/notebooks/p5/notebooks/imagenes/drawing-05.svg
new file mode 100644
index 0000000..963e0e7
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-05.svg
@@ -0,0 +1,116 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-06.png b/notebooks/p5/notebooks/imagenes/drawing-06.png
new file mode 100644
index 0000000..375af12
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-06.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-06.svg b/notebooks/p5/notebooks/imagenes/drawing-06.svg
new file mode 100644
index 0000000..31823f7
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-06.svg
@@ -0,0 +1,166 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-07.png b/notebooks/p5/notebooks/imagenes/drawing-07.png
new file mode 100644
index 0000000..5cd82c9
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-07.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-07.svg b/notebooks/p5/notebooks/imagenes/drawing-07.svg
new file mode 100644
index 0000000..fb53aaf
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-07.svg
@@ -0,0 +1,170 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-08.png b/notebooks/p5/notebooks/imagenes/drawing-08.png
new file mode 100644
index 0000000..7235d48
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-08.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-08.svg b/notebooks/p5/notebooks/imagenes/drawing-08.svg
new file mode 100644
index 0000000..6d1bb4b
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-08.svg
@@ -0,0 +1,149 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-09.png b/notebooks/p5/notebooks/imagenes/drawing-09.png
new file mode 100644
index 0000000..0ebbdcd
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-09.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-09.svg b/notebooks/p5/notebooks/imagenes/drawing-09.svg
new file mode 100644
index 0000000..75508be
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-09.svg
@@ -0,0 +1,160 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-10.png b/notebooks/p5/notebooks/imagenes/drawing-10.png
new file mode 100644
index 0000000..26d3524
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-10.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-10.svg b/notebooks/p5/notebooks/imagenes/drawing-10.svg
new file mode 100644
index 0000000..b4efcda
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-10.svg
@@ -0,0 +1,164 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-11.png b/notebooks/p5/notebooks/imagenes/drawing-11.png
new file mode 100644
index 0000000..ab2be57
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-11.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-11.svg b/notebooks/p5/notebooks/imagenes/drawing-11.svg
new file mode 100644
index 0000000..299a71b
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-11.svg
@@ -0,0 +1,164 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/drawing-12.png b/notebooks/p5/notebooks/imagenes/drawing-12.png
new file mode 100644
index 0000000..e08816c
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/drawing-12.png differ
diff --git a/notebooks/p5/notebooks/imagenes/drawing-12.svg b/notebooks/p5/notebooks/imagenes/drawing-12.svg
new file mode 100644
index 0000000..68c08c7
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/drawing-12.svg
@@ -0,0 +1,169 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/example_1_3.png b/notebooks/p5/notebooks/imagenes/example_1_3.png
new file mode 100644
index 0000000..aeee179
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/example_1_3.png differ
diff --git a/notebooks/p5/notebooks/imagenes/example_1_4.png b/notebooks/p5/notebooks/imagenes/example_1_4.png
new file mode 100644
index 0000000..be6317e
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/example_1_4.png differ
diff --git a/notebooks/p5/notebooks/imagenes/grayscale.svg b/notebooks/p5/notebooks/imagenes/grayscale.svg
new file mode 100644
index 0000000..1f95aa3
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/grayscale.svg
@@ -0,0 +1,23 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/hsb.png b/notebooks/p5/notebooks/imagenes/hsb.png
new file mode 100644
index 0000000..502d438
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/hsb.png differ
diff --git a/notebooks/p5/notebooks/imagenes/order.svg b/notebooks/p5/notebooks/imagenes/order.svg
new file mode 100644
index 0000000..7aa1776
--- /dev/null
+++ b/notebooks/p5/notebooks/imagenes/order.svg
@@ -0,0 +1,19 @@
+
+
+
+
\ No newline at end of file
diff --git a/notebooks/p5/notebooks/imagenes/rgb.jpg b/notebooks/p5/notebooks/imagenes/rgb.jpg
new file mode 100644
index 0000000..692491a
Binary files /dev/null and b/notebooks/p5/notebooks/imagenes/rgb.jpg differ
diff --git a/notebooks/p5/notebooks/interactividad.ipynb b/notebooks/p5/notebooks/interactividad.ipynb
new file mode 100644
index 0000000..897cc6c
--- /dev/null
+++ b/notebooks/p5/notebooks/interactividad.ipynb
@@ -0,0 +1,1041 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# [Interactividad](https://p5.readthedocs.io/en/latest/tutorials/interactivity.html)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Interactividad\n",
+ "La pantalla forma un puente entre nuestros cuerpos y el reino de los circuitos y electricidad dentro de las computadoras. Controlamos los elementos en una pantalla a través de una variedad de dispositivos como trackpads, joysticks y pantallas táctiles, pero el teclado y el mouse siguen siendo el dispositivo de entrada más común en las computadoras de escritorio. La historia del mouse de computadora empieza allá por los 60s, cuando Douglas Engelbart presento el dispositivo como un elemento del oN-Line System (NLS), una de los primeros sistemas de computadora con una pantalla de video. El concepto del mouse fue más desarrollado en el Xerox Palo Alto Research Center (PARC), pero su introducción con la Macintosh de Apple en 1984 fue el catalizador para su inmensa popularidad. El diseño del mouse fue cambiando a medida que pasaron los años, pero su función sigue siendo la misma. En la patente original de Engelbart de 1970 se refería al mouse como 'un indicador de posiciones X-Y', y esto sigue siendo correcto, pero define a secas su uso contemporaneo.\n",
+ "\n",
+ "El mouse como objeto fisico es usado para controlar la posición del cursor en la pantalla y seleccionar elementos de una interfaz. La posición del cursor es leída por un programa de computadora como dos numeros, la coordenada X y la coordenada Y. Estos números pueden ser usados para controlar atributos de los elementos en la pantalla. Si estas coordenadas son guardadas y analizadas, podemos extraer información de alto-nivel como la velocidad y la dirección del mouse. Estos datos a su vez pueden ser usados para gestos y reconocimiento de patrones.\n",
+ "\n",
+ "Los teclados son tipicamente usados para introducir caracteres y escribir documentos, emails, o mensajes de chat; pero el teclado tiene un potencial de uso que va más allá del que tuvo cuando fue originalmente concebido. La migración del teclado de una máquina de escribir a una computadora expandió su funcionalidad hasta permitirnos lanzar software, movernos a través de menus de aplicaciones, y navegar entornos 3D en videojuegos. Cuando escribimos nuestro propio software, tenemos la libertad de usar los datos del teclado de la forma que querramos. Por ejemplo, información básica como la velocidad y el ritmo de los dedos pueden ser determinados a partir de la frecuencia en la que las teclas son presionadas. Esta información puede controlar la velocidad de un evento o la precisión de un movimiento. También es posible ignorar los caracteres impresos en el teclado mismo y usar la ubicación de cada tecla como posiciones numericas.\n",
+ "\n",
+ "El teclado de computadora moderno es un descendiente directo de la máquina de escribir. La posición de las teclas son heredadas de las máquinas de escribir más antiguas. La distribución del teclado se llama QWERTY por el orden de las teclas de la fila de arriba.\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Datos del mouse\n",
+ "Las variables `mouse_x` y `mouse_y` de Processing almacenan las coordenadas X y las coordenadas Y del cursor relativo al origen de la esquina superior izquierda de la ventana. Para ver los valores que se producen cuando movemos el mouse, corran este programa para imprimir los valores en la consola:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def draw():\n",
+ " cuadro_rate(12)\n",
+ " print(mouse_x, ' : ', mouse_y)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Cuando el programa inicie, las valores de `mouse_x` y `mouse_y` van a ser 0. Si el cursor se mueve dentro de la ventana, los valores van a ser la posición actual del cursor. Si el cursor está a la izquierda, el valor `mouse_x` es 0 y el valor aumenta a medida que el cursor se mueve a la derecha. Si el cursor está arriba, el valor de `mouse_y` es 0 y su valor aumenta a medida que el cursor se mueve para abajo. Si `mouse_x` y `mouse_y` son usados en programas sin `draw` o si `no_loop()` está dentro de `setup()`, los valores siempre van a ser 0. \n",
+ "\n",
+ "La posición del mouse es comunmente usada para controlar la ubicación de los elementos visuales en pantalla. Relaciones más interesantes pueden crearse cuando el elemento visual se relaciona de forma diferente según los valores del mouse, en vez de imitar la posición actual. Añadir y restar valores de la posición del mouse crea relaciones que quedan constantes, mientras que multiplicar y dividir estos valores crean relaciones visuales cambiantes entre la posición del mouse y los elementos en la pantalla. En el primero de los siguientes ejemplos, el circulo es directamente mapeado al cursor, en el segundo, números son sumados y restado de la posición del cursor para crear desfases, y en el tercero, usamos multiplicación y división para escalar los desfases.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ "\n",
+ "def draw():\n",
+ " background(126)\n",
+ " ellipse((mouse_x, mouse_y), 33, 33)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ "\n",
+ "def draw():\n",
+ " background(126)\n",
+ " ellipse((mouse_x, 16), 33, 33) # Circulo superior\n",
+ " ellipse((mouse_x+20, 50), 33, 33) # Circulo del medio\n",
+ " ellipse((mouse_x-20, 84), 33, 33) # Circulo inferior\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Para invertir los valores del mouse, restamos el valor `mouse_x` del ancho de la ventana y restamos el valor `mouse_y` del alto de la ventana."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ "\n",
+ "def draw():\n",
+ " background(126)\n",
+ " x = mouse_x\n",
+ " y = mouse_y\n",
+ " ix = width - mouse_x # Invertir X\n",
+ " iy = height - mouse_y # Invertir Y\n",
+ " background(126)\n",
+ " fill(255, 150)\n",
+ " ellipse((x, height/2), y, y)\n",
+ " fill(0, 159)\n",
+ " ellipse((ix, height/2), iy, iy)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Las variables `pmouse_x` y `pmouse_y` de Processing almacenan los valores del mouse del cuadro (cuadro) anterior. Si el mouse no se mueve, los valores serán los mismos, pero si el mouse se está movimiento rápido va a haber una diferencia grande entre estos valores. Para ver la diferencia, corramos el siguiente programa y movamos el mouse lentamente y rápidamente. Vean los valores que se imprimen en la consola."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def draw():\n",
+ " cuadro_rate(12)\n",
+ " print(pmouse_y - mouse_x)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Dibujen una linea desde la posición previa del mouse a la actual para mostrar el cambio de dirección en un cuadro y revelar la velocidad y la dirección del mouse. Cuando el mouse no se está moviendo, un punto es dibujado, pero movimientos rápidos del mouse crean lineas largas.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " stroke_weight(8)\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " line(mouse_x, mouse_y, pmouse_x, pmouse_y)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Usen las variables `mouse_x` y `mouse_y` con una estructura if para permitir que el cursor seleccione regiones de la pantalla. Los siguientes ejemplos demuestran al cursor seleccionando diferentes areas de la ventana. El primero divide la pantalla en mitades, y el segundo en tercios."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ " fill(0)\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " if mouse_x < 50:\n",
+ " rect((0, 0), 50, 100)\n",
+ " else:\n",
+ " rect((50, 0), 50, 100)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Usen los operadores lógicos `and` con una estructura `if` para seleccionar una región rectangular de la pantalla. Como es demostrado en el siguiente ejemplo, cuando se le pide a una expresión relacional que pruebe si cada punta del rectangulo (izquierda, derecha, arriba, abajo) y éstas están concatenadas con un operador `AND`, la expresión entera es verdadera solo cuando el cursor está dentro del rectangulo."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ " fill(0)\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " if ((mouse_x > 40) and (mouse_x < 80) and\n",
+ " (mouse_y > 20) and (mouse_y < 80)):\n",
+ " fill(255)\n",
+ " else:\n",
+ " fill(0)\n",
+ "\n",
+ " rect((40, 20), 40, 60)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Este código pregunta, 'está el cursor a la derecha del borde izquierda y está el cursor a la izquierda del borde derecha y está el cursor más allá del borde de arriba y está el cursor arriba del borde de abajo?' El código para nuestro próximo ejemplo nos pregunta una serie de preguntas similares y las combina con la palabra clave else para determinar cual de las areas definidas contiene el cursor. \n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ " fill(0)\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " if (mouse_x <= 50) and (mouse_y <= 50):\n",
+ " rect((0, 0), 50, 50) # superior-izquierda\n",
+ " elif (mouse_x <= 50) and (mouse_y > 50):\n",
+ " rect((0, 50), 50, 50) # inferior-izquierda\n",
+ " elif (mouse_x > 50) and (mouse_y <= 50):\n",
+ " rect((50, 0), 50, 50) # superior-derecha\n",
+ " else:\n",
+ " rect((50, 50), 50, 50) # inferior-derecha\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Botones del mouse\n",
+ "Los mouse de computadoras tipicamente tienen entre uno y tres botones; Processing puede detectar cuando estos botones están presionados con las variables `mouse_is_pressed` y `mouse_button`. La posición del cursor junto con la habilidad de saber cuando el mouse está presionado nos permite hacer diferentes acciones. Por ejemplo, un botón presionado cuando el mouse está arriba de un ícono puede seleccionarlo, así el ícono puede ser transladado a un lugar diferente de la pantalla. La variable `mouse_is_pressed` es verdadera si cualquier botón del mouse es apretado y falsa cuando no hay ningún botón del mouse apretado. La variable `mouse_button` es LEFT, CENTER o RIGHT dependiendo en el botón del mouse que fue más recientemente apretado. La variable `mouse_is_pressed` se vuelve falsa apenas el botón se deja de apretar, pero la variable `mouse_button` mantiene su valor hasta que otro botón es apretado. Estas variables pueden ser usadas de forma independiente o en conjunto para controlar el software. Corran estos programas y vean como reaccionan.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ "\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " if mouse_is_pressed:\n",
+ " fill(255)\n",
+ " else:\n",
+ " fill(0)\n",
+ " rect((25, 25), 50, 50)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Datos del teclado\n",
+ "Processing registra la tecla que se apretó más recientemente y si hay una tecla que está siendo presionada en este momento. La variable booleana `key_is_pressed` es verdadera si una tecla está siendo apretada y es falsa cuando no. Incluyan esta variable en una estructura if para permitir que las lineas de código se ejecuten solo cuando una tecla es presionada. La variable `key_is_pressed` se mantiene verdadera mientras que la tecla sea sostenida en su posición presionada y solo se vuelve falsa cuando la tecla se suelta.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " stroke_weight(4)\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ "\n",
+ " if key_is_pressed:\n",
+ " line((20, 20), (80, 80))\n",
+ " else:\n",
+ " rect((40, 40), 20, 20)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "La variable `key` almacena un solo caracter alfanumerico. Especificamente, almacena la tecla que se apretó por última vez. La tecla puede ser mostrada en la pantalla con la función `text()`\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " text_size(60)\n",
+ "\n",
+ "def draw():\n",
+ " background(0)\n",
+ " text(key, 20, 75) # Draw at coordinate (20,75)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "La variable `key` puede ser usada para determinar si una tecla especifica fue apretada. En el próximo ejemplo usamos la expresión `key == 'A'` para ver si se apretó la tecla A. Usamos las comillas simples para aclarar que es un dato de tipo char. Si usaramos comillas dobles correriamos el riesgo de que se interprete como un string, y eso puede causar problemas ya que no es posible comparar un string a un char de forma directa. El operador lógico AND se usa para conectar la expresión con la variable `key_is_pressed` y ver si efectivamente se presionó la A mayúscula.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " stroke_weight(4)\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " # Si la 'A' esta siendo apretada dibujame una linea\n",
+ " if key_is_pressed and key == 'A':\n",
+ " line((50, 25), (50, 75))\n",
+ " else: # Sino, dibuja un elipse\n",
+ " ellipse((50, 50), 50, 50)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
\n",
+ "El ejemplo anterior solo funciona con la A mayúscula, pero no con la minúscula. ¿Cómo modificarían el código para que funcionara con la minúscula también?\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Teclas especiales\n",
+ "Además de ser capaces de leer los valores de las teclas para números, letras y simbolos, Processing también nos deja leer los valores de otras teclas incluyendo las flechas de dirección, Alt, Ctrl, Shift, Retroceso, Tab, Enter, Escape, etc. La variable `keyCode` almacena las teclas ALT, CONTROL, SHIFT, UP, DOWN, LEFT y RIGHT como constantes. Antes de determinar cual tecla es apretada, es necesario fijarse si la tecla es especial o no.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "y = 35\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ "\n",
+ "def draw():\n",
+ " global y\n",
+ " background(204)\n",
+ " line((10, 50), (90, 50))\n",
+ "\n",
+ " if key == 'UP':\n",
+ " y = 20\n",
+ " elif key == 'DOWN':\n",
+ " y = 50\n",
+ " else:\n",
+ " y = 35\n",
+ "\n",
+ " rect((25, y), 50, 30)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Eventos\n",
+ "Los eventos son una categoria de funciones que alteran el flujo normal de un programa cuando una acción como presionar una tecla o mover el mouse ocurre. Las presiones de teclas y los movimientos de mouse son guardados hasta el final de `draw()`, donde pueden tomar acción sin molestar a lo que se está dibujando en ese momento. El código dentro de una función evento es ejecutado cada vez que el evento que corresponde ocurre. Por ejemplo, si un botón del mouse es apretado, el código dentro de la función `mouse_pressed()` va a ejecutarse una vez y no va a ejecutarse de vuelta hasta que el botón sea presionado nuevamente. Esto permite que los datos producidos por el mouse y el teclado sean leidos independientemente de lo que pasa en el resto del programa.\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Eventos de mouse\n",
+ "Las funciones evento para el mouse son las siguientes: `mouse_pressed()`, `mouse_released()`, `mouse_moved()` y `mouse_dragged()`.\n",
+ "* `mouse_pressed()`: El código dentro de este bloque se ejecuta una vez que un botón del mouse es apretado.\n",
+ "* `mouse_released()`: El código dentro de este bloque se ejecuta una vez que un botón del mouse es soltado.\n",
+ "* `mouse_moved()`: El código dentro de este bloque se ejecuta una vez que un botón del mouse es movido.\n",
+ "* `mouse_dragged()`: El código dentro de este bloque se ejecuta una vez que un botón del mouse se mantiene apretado mientras se mueve.\n",
+ "\n",
+ "La función `mouse_pressed()` funciona diferente que la variable `mouse_is_pressed`. El valor de la variable `mouse_is_pressed` es verdadero hasta que el botón del mouse es soltado. Por lo que puede usarse dentro de `draw()` para ejecutar una linea de código cuando el mouse es apretado. En contraste, el código dentro de la función `mouse_pressed()` solo se ejecuta una vez cuando el botón es apretado. Esto lo hace útil para cuando un click del mouse es usado para una acción especifica, como limpiar la pantalla. En el ejemplo siguiente, el color de fondo se hace más claro cada vez que el botón del mouse es presionado.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "gris = 0\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ "\n",
+ "def draw():\n",
+ " background(gris)\n",
+ "\n",
+ "def mouse_pressed():\n",
+ " global gris\n",
+ " gris += 20\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "El siguiente ejemplo es el mismo que el de arriba, pero la variable `gris` se establece en la función de evento `mouse_released()`, que es llamada siempre que un botón es soltado. Esta diferencia solo puede ser vista corriendo el programa y apretando el boton del mouse.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "gris = 0\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ "\n",
+ "def draw():\n",
+ " background(gris)\n",
+ "\n",
+ "def mouse_released():\n",
+ " global gris\n",
+ " gris += 20\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Por lo general no es una buena idea dibujar dentro de una función de evento, pero puede hacerse bajo ciertas condiciones. Antes de dibujar dentro de estas funciones, es importante pensar en como 'fluye' el programa. En este ejemplo, cuadrados son dibujados dentro de `mouse_pressed()` y se mantienen en la pantalla porque no hay ningún `background()` dentro de `draw()`. Pero si `background()` es usado, los elementos visuales dibujados dentro de una de las funciones de evento del mouse van a aparecer solo por un cuadro, o, por defecto, 1/60 de segundo. De hecho, van a notar que este ejemplo no tiene nada dentro de `draw()`, pero necesitamos que esté ahí para que la librería siga escuchando los eventos. Si una función `background()` fuera ejecutada dentro de `draw()`, los rectangulos aparecerían en la pantalla para solo desaparecer inmediatamente después.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " fill(0, 102)\n",
+ "\n",
+ "def draw():\n",
+ " # El draw() vacio hace que el programa siga ejecutandose\n",
+ " pass\n",
+ "\n",
+ "def mouse_pressed():\n",
+ " rect((mouse_x, mouse_y), 33, 33)\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "El código dentro de las funciones de evento `mouse_moved()` y `mouse_dragged()` son ejecutadas cuando hay un cambio en la posición del mouse. El código dentro del bloque `mouse_moved()` se ejecuta al final de cada cuadro cuando el mouse se mueve y ningún botón es presionado. El código dentro del bloque de `mouse_dragged()` hace lo mismo pero cuando un botón del mouse es presionado. Si el mouse se mantiene en la misma posición cuadro a cuadro, el código dentro de estas funciones no se ejecuta. En este ejemplo, el circulo gris sigue al mouse cuando el botón no está siendo presionado, y el circulo negro sigue al mouse cuando un botón si está siendo presionado.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "arrastreX, arrastreY, moverX, moverY = (0, 0, 0, 0)\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ " fill(0)\n",
+ "\n",
+ " ellipse((arrastreX, arrastreY), 33, 33) # Circulo negro\n",
+ " fill(153)\n",
+ " ellipse((moverX, moverY), 33, 33) # Circulo gris\n",
+ "\n",
+ "def mouse_moved():\n",
+ " moverX = mouse_x\n",
+ " moverY = mouse_y\n",
+ "\n",
+ "def mouse_dragged():\n",
+ " arrastreX = mouse_x\n",
+ " arrastreY = mouse_y\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Eventos de teclas\n",
+ "Cada vez que una tecla es presionada, las funciones `key_pressed()` y `key_released()` lo registran:\n",
+ "* `key_pressed()`: El código dentro de este bloque se ejecuta una vez cuando cualquier tecla es presionada. \n",
+ "* `key_released`: El código dentro de este bloque se ejecuta una vez cuando cualquier tecla se suelta. \n",
+ "\n",
+ "Dentro del bloque `key_pressed()` es posible determinar cual tecla fue presionada y usar ese valor para lo que querramos. Si una tecla es presionada por un tiempo extendido, el código dentro del bloque `key_pressed()` va a ejecutarse varias veces de forma rápida. ¿Qué tan rápido? Eso dependerá de la computadora que estés usando, puede varíar dependiendo las características. En este ejemplo, los valores de la variable booleana `dibujarT` se establece como `true` una vez que la tecla T es apretada, esto causa que el bloque de código de `draw()` se empiece a ejecutar.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "dibujarT = False\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ " no_stroke()\n",
+ "\n",
+ "def draw():\n",
+ " background(204)\n",
+ "\n",
+ " global dibujarT\n",
+ " if dibujarT:\n",
+ " rect((20, 20), 60, 20)\n",
+ " rect((39, 40), 22, 45)\n",
+ "\n",
+ "\n",
+ "def key_pressed():\n",
+ " global dibujarT\n",
+ " if key == 'T' or key == 't':\n",
+ " dibujarT = True\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
",
+ "",
+ "",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Flujo de eventos\n",
+ "Como discutimos antes, los programas que contienen un bloque `draw()` muestran 60 cuadros por cada segundo en pantalla. El parámetro `cuadro_rate` puede pasarse a la función `run()` para limitar el número de cuadros que se mostrarán cada segundo, y la función `no_loop()` puede ser usada para hacer que `draw()` deje de iterar. Las funciones adicionales `loop()` y `redraw()` proveen más opciones que podemos usar en combinación con las funciones de eventos de teclado y mouse. Si un programa fue pausado con la función `no_loop()`, ejecutando la función `loop()` resumirá su acción. Porque las funciones de evento son los únicos elementos que continuan ejecutandose cuando el programa fue pausado con `no_loop()`, la función `loop()` puede ser usada dentro de estos eventos para continuar con la ejecución de `draw()`. Piensen, ¿donde se les ocurre que podrían usar esta funcionalidad dentro de un juego? \n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from p5 import *\n",
+ "\n",
+ "cuadro = 0\n",
+ "\n",
+ "def setup():\n",
+ " size(100, 100)\n",
+ "\n",
+ "def draw():\n",
+ " global cuadro\n",
+ " if cuadro > 120: # Si pasaron 120 cuadros desde que\n",
+ " no_loop() # se movio el mouse, detenemos el programa\n",
+ " background(0) # y hacemos el fondo negro.\n",
+ " else:\n",
+ " background(204) # fondo gris claro y dibujamos lineas\n",
+ " line((mouse_x, 0), (mouse_x, 100)) # en las posiciones del mouse\n",
+ " line((0, mouse_y), (100, mouse_y))\n",
+ " cuadro += 1\n",
+ "\n",
+ "def mouse_pressed():\n",
+ " global cuadro\n",
+ " loop()\n",
+ " cuadro = 0\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " run()\n"
+ ]
+ }
+ ],
+
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "languedad": "python",
+ "name": "python3"
+ },
+ "languedad_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}