From 6f5d5f8c519eb89b5d4aaa0fc6280282f17ebf0b Mon Sep 17 00:00:00 2001 From: agus pas Date: Tue, 31 Oct 2023 12:44:06 -0300 Subject: [PATCH 1/3] actualizacion --- "M02_introprogramaci\303\263n/Practica.ipynb" | 2 +- .../Prep_Course_Homework_03.ipynb | 429 ++++++++++++---- .../Prep_Course_Homework_03.py | 69 ++- .../Prep_Course_Homework_04.ipynb | 461 ++++++++++++++++-- 4 files changed, 800 insertions(+), 161 deletions(-) diff --git "a/M02_introprogramaci\303\263n/Practica.ipynb" "b/M02_introprogramaci\303\263n/Practica.ipynb" index b35d69666..4aa588a1b 100644 --- "a/M02_introprogramaci\303\263n/Practica.ipynb" +++ "b/M02_introprogramaci\303\263n/Practica.ipynb" @@ -69,7 +69,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.8.10" }, "orig_nbformat": 4 }, diff --git a/M03_variablesydatos/Prep_Course_Homework_03.ipynb b/M03_variablesydatos/Prep_Course_Homework_03.ipynb index b4d68b08b..ab3864c37 100644 --- a/M03_variablesydatos/Prep_Course_Homework_03.ipynb +++ b/M03_variablesydatos/Prep_Course_Homework_03.ipynb @@ -18,10 +18,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12\n" + ] + } + ], + "source": [ + "a=12\n", + "print(a)\n" + ] }, { "attachments": {}, @@ -33,10 +44,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(8.5)\n" + ] }, { "attachments": {}, @@ -48,10 +72,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a=12\n", + "type(a)\n" + ] }, { "attachments": {}, @@ -63,10 +101,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "c=\"agustin\"\n" + ] }, { "attachments": {}, @@ -78,10 +118,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "d=complex(2,4)\n" + ] }, { "attachments": {}, @@ -93,10 +135,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print(type(d))\n" + ] }, { "attachments": {}, @@ -108,10 +160,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "pi = 3.1416\n" + ] }, { "attachments": {}, @@ -123,10 +177,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "var1 = 'True'\n", + "var2 = True" + ] }, { "attachments": {}, @@ -138,10 +195,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "bool" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(var1)\n", + "type(var2)" + ] }, { "attachments": {}, @@ -153,10 +224,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "f=5.6+1\n" + ] }, { "attachments": {}, @@ -168,10 +241,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(9+7j)\n" + ] + } + ], + "source": [ + "g = 6 + 4j\n", + "h = 3 + 3j\n", + "print(g + h)" + ] }, { "attachments": {}, @@ -183,10 +268,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(9+7j)\n" + ] + } + ], + "source": [ + "g = 6 + 4j\n", + "h = 3 + 3j\n", + "print(g + h)" + ] }, { "attachments": {}, @@ -198,10 +295,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(9+4j)\n" + ] + } + ], + "source": [ + "k = 6 + 4j\n", + "l = 3\n", + "print(k + l)" + ] }, { "attachments": {}, @@ -213,10 +322,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "256\n" + ] + } + ], + "source": [ + "print(2**8)\n" + ] }, { "attachments": {}, @@ -228,10 +347,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6.75\n" + ] + } + ], + "source": [ + "print(27/4)\n" + ] }, { "attachments": {}, @@ -243,10 +372,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6\n" + ] + } + ], + "source": [ + "print(27//4)\n" + ] }, { "attachments": {}, @@ -258,10 +397,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "print(27%4)\n" + ] }, { "attachments": {}, @@ -273,10 +422,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "27\n" + ] + } + ], + "source": [ + "print((4*(27//4))+(27%4))\n" + ] }, { "attachments": {}, @@ -288,10 +447,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a=\"a34\"\n", + "b=\"g45\"\n", + "Print=(a+b)" + ] }, { "attachments": {}, @@ -303,10 +466,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 == '2'\n" + ] }, { "attachments": {}, @@ -318,10 +494,27 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "num='2'\n", + "num2=int(num)\n", + "type(num2)\n", + "\n", + "2 == num2" + ] }, { "attachments": {}, @@ -333,10 +526,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a = float('3')\n" + ] }, { "attachments": {}, @@ -348,10 +543,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], + "source": [ + "a=3\n", + "b=1\n", + "a-=b\n", + "print(a)" + ] }, { "attachments": {}, @@ -363,10 +571,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1<<2\n" + ] }, { "attachments": {}, @@ -378,10 +599,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4.0" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "float(2) + float('2')\n" + ] }, { "attachments": {}, @@ -393,10 +627,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'22'" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2 * '2'" + ] } ], "metadata": { @@ -418,7 +665,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.8.10" } }, "nbformat": 4, diff --git a/M03_variablesydatos/Prep_Course_Homework_03.py b/M03_variablesydatos/Prep_Course_Homework_03.py index eb7ddb9eb..103d206f5 100644 --- a/M03_variablesydatos/Prep_Course_Homework_03.py +++ b/M03_variablesydatos/Prep_Course_Homework_03.py @@ -7,6 +7,8 @@ # In[7]: +a=10 +print(a) @@ -14,6 +16,8 @@ # In[3]: +b=8.5 +print(type(b)) @@ -21,7 +25,7 @@ # 3) Imprimir el tipo de dato de la variable creada en el punto 1 # In[8]: - +print(type(a)) @@ -30,22 +34,20 @@ # In[2]: - - +c="agustin" # 5) Crear una variable que contenga un número complejo # In[3]: - - +d=complex(2,4) # 6) Mostrar el tipo de dato de la variable crada en el punto 5 # In[4]: - +print(type(d)) @@ -63,7 +65,8 @@ - +var1 = 'True' +var2 = True # 9) Imprimir el tipo de dato correspondientes a las variables creadas en el punto 8 @@ -71,13 +74,15 @@ +type(var1) +type(var2) # 10) Asignar a una variable, la suma de un número entero y otro decimal # In[1]: - +f=5.6+1 @@ -85,7 +90,9 @@ # In[2]: - +g = 6 + 4j +h = 3 + 3j +print(g + h) @@ -93,7 +100,9 @@ # In[4]: - +g = 6 + 4j +h = 3 + 3j +print(g + h) @@ -101,7 +110,9 @@ # In[5]: - +k = 6 + 4j +l = 3 +print(k + l) @@ -109,7 +120,7 @@ # In[6]: - +print(2**8) # 15) Obtener el cociente de la división de 27 entre 4 en una variable y luego mostrarla @@ -117,6 +128,7 @@ # In[8]: +print(27/4) @@ -124,6 +136,7 @@ # In[9]: +print(27//4) @@ -132,7 +145,7 @@ # In[1]: - +print(27%4) @@ -141,22 +154,22 @@ # In[2]: - - +print((4*(27//4))+(27%4)) # 19) Utilizar el operador "+" en una operación donde intervengan solo variables alfanuméricas # In[3]: - - +a="a34" +b="g45" +Print=(a+b) # 20) Evaluar si "2" es igual a 2. ¿Por qué ocurre eso? # In[4]: - +2 == '2' @@ -164,16 +177,17 @@ # In[11]: +num='2' +num2=int(num) +type(num2) - - +2 == num2 # 22) ¿Por qué arroja error el siguiente cambio de tipo de datos? a = float('3,8') # In[12]: - - +a = float('3') # 23) Crear una variable con el valor 3, y utilizar el operador '-=' para modificar su contenido y que de como resultado 2. @@ -181,14 +195,17 @@ # In[15]: - +a=3 +b=1 +a-=b +print(a) # 24) Realizar la operacion 1 << 2 ¿Por qué da ese resultado? ¿Qué es el sistema de numeración binario? # In[29]: - +1<<2 @@ -197,7 +214,7 @@ # In[23]: - +float(2) + float('2') @@ -206,4 +223,4 @@ # In[30]: - +2 * '2' diff --git a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb index 8b5ecb46c..8f76ee5aa 100644 --- a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb +++ b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb @@ -18,10 +18,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "19 es mayor a cero\n" + ] + } + ], + "source": [ + "a=19\n", + "if a>10:\n", + " print(a, \"es mayor a cero\")\n" + ] }, { "attachments": {}, @@ -33,10 +45,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "no son del mismo tipo\n" + ] + } + ], + "source": [ + "a=10\n", + "b=\"hola\"\n", + "if (type(a)==type(b)):\n", + " print(\"son del mismo tipo\")\n", + "else:\n", + " print(\"no son del mismo tipo\")\n" + ] }, { "attachments": {}, @@ -48,10 +75,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 no es par\n", + "2 es par\n", + "3 no es par\n", + "4 es par\n", + "5 no es par\n", + "6 es par\n", + "7 no es par\n", + "8 es par\n", + "9 no es par\n", + "10 es par\n", + "11 no es par\n", + "12 es par\n", + "13 no es par\n", + "14 es par\n", + "15 no es par\n", + "16 es par\n", + "17 no es par\n", + "18 es par\n", + "19 no es par\n", + "20 es par\n" + ] + } + ], + "source": [ + "for n in range(1, 21):\n", + " if n % 2 == 0:\n", + " print(n, \"es par\")\n", + " else:\n", + " print(str(n), \"no es par\")" + ] }, { "attachments": {}, @@ -63,10 +123,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 elevado a la 3, es igual a = 0\n", + "1 elevado a la 3, es igual a = 1\n", + "2 elevado a la 3, es igual a = 8\n", + "3 elevado a la 3, es igual a = 27\n", + "4 elevado a la 3, es igual a = 64\n", + "5 elevado a la 3, es igual a = 125\n" + ] + } + ], + "source": [ + "for n in range(0, 6):\n", + " print(n, \" elevado a la 3, es igual a = \", (n**3))" + ] }, { "attachments": {}, @@ -78,10 +154,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n" + ] + } + ], + "source": [ + "n=6\n", + "for i in range(1, n+1):\n", + " print(i)" + ] }, { "attachments": {}, @@ -93,10 +186,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "El factorial es 25\n" + ] + } + ], + "source": [ + "n = 5\n", + "if (type(n) == int):\n", + " if (n > 0):\n", + " factorial = n * n\n", + " print('El factorial es', factorial)\n", + " else:\n", + " print('La variable no es mayor a cero')\n", + "else:\n", + " print('La variable no es un entero')" + ] }, { "attachments": {}, @@ -108,10 +219,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5 es mayor que cero\n", + "5 es mayor que cero\n", + "5 es mayor que cero\n", + "5 es mayor que cero\n", + "5 es mayor que cero\n", + "4 es mayor que cero\n", + "4 es mayor que cero\n", + "4 es mayor que cero\n", + "4 es mayor que cero\n", + "3 es mayor que cero\n", + "3 es mayor que cero\n", + "3 es mayor que cero\n", + "2 es mayor que cero\n", + "2 es mayor que cero\n", + "1 es mayor que cero\n" + ] + } + ], + "source": [ + "n=6\n", + "while n > 0:\n", + " n -= 1\n", + " for i in range (1, n+1):\n", + " print(n, \"es mayor que cero\")\n", + " " + ] }, { "attachments": {}, @@ -123,10 +263,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 no es par\n", + "2 es par\n", + "3 no es par\n", + "4 es par\n", + "5 no es par\n", + "6 es par\n" + ] + } + ], + "source": [ + "n=6\n", + "for i in range(1, n+1):\n", + " while i % 2 == 0:\n", + " print(i, \"es par\")\n", + " break\n", + " else:\n", + " print(i, \"no es par\")\n" + ] }, { "attachments": {}, @@ -138,10 +299,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "5\n", + "7\n", + "11\n", + "13\n", + "17\n", + "19\n", + "23\n", + "29\n" + ] + } + ], + "source": [ + "tope_rango=30\n", + "n = 0\n", + "primo = True\n", + "while (n < tope_rango):\n", + " for div in range(2, n):\n", + " if (n % div == 0):\n", + " primo = False\n", + " if (primo):\n", + " print(n)\n", + " else:\n", + " primo = True\n", + " n += 1" + ] }, { "attachments": {}, @@ -153,10 +346,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "5\n", + "7\n", + "11\n", + "13\n", + "17\n", + "19\n", + "23\n", + "29\n" + ] + } + ], + "source": [ + "tope_rango=30\n", + "n = 0\n", + "primo = True\n", + "while (n < tope_rango):\n", + " for div in range(2, n):\n", + " if (n % div == 0):\n", + " primo = False\n", + " break\n", + " if (primo):\n", + " print(n)\n", + " else:\n", + " primo = True\n", + " n += 1" + ] }, { "attachments": {}, @@ -168,10 +394,77 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "5\n", + "7\n", + "11\n", + "13\n", + "17\n", + "19\n", + "23\n", + "29\n", + "Cantidad de ciclos: 378\n", + "0\n", + "1\n", + "2\n", + "3\n", + "5\n", + "7\n", + "11\n", + "13\n", + "17\n", + "19\n", + "23\n", + "29\n", + "Cantidad de ciclos: 134\n", + "Se optimizó a un 0.3544973544973545% de ciclos aplicando break\n" + ] + } + ], + "source": [ + "tope_rango=30\n", + "ciclos_sin_break = 0\n", + "n = 0\n", + "primo = True\n", + "while (n < tope_rango):\n", + " for div in range(2, n):\n", + " ciclos_sin_break += 1\n", + " if (n % div == 0):\n", + " primo = False\n", + " if (primo):\n", + " print(n)\n", + " else:\n", + " primo = True\n", + " n += 1\n", + "print('Cantidad de ciclos: ' + str(ciclos_sin_break))\n", + "\n", + "ciclos_con_break = 0\n", + "n = 0\n", + "primo = True\n", + "while (n < tope_rango):\n", + " for div in range(2, n):\n", + " ciclos_con_break += 1\n", + " if (n % div == 0):\n", + " primo = False\n", + " break\n", + " if (primo):\n", + " print(n)\n", + " else:\n", + " primo = True\n", + " n += 1\n", + "print('Cantidad de ciclos: ' + str(ciclos_con_break))\n", + "print('Se optimizó a un ' + str(ciclos_con_break/ciclos_sin_break) + '% de ciclos aplicando break')" + ] }, { "attachments": {}, @@ -183,10 +476,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "108 es divisible por 12\n", + "120 es divisible por 12\n", + "132 es divisible por 12\n", + "144 es divisible por 12\n", + "156 es divisible por 12\n", + "168 es divisible por 12\n", + "180 es divisible por 12\n", + "192 es divisible por 12\n", + "204 es divisible por 12\n", + "216 es divisible por 12\n", + "228 es divisible por 12\n", + "240 es divisible por 12\n", + "252 es divisible por 12\n", + "264 es divisible por 12\n", + "276 es divisible por 12\n", + "288 es divisible por 12\n", + "300 es divisible por 12\n" + ] + } + ], + "source": [ + "tope_rango=301\n", + "n = 99\n", + "while (n < tope_rango):\n", + " n += 1\n", + " if (n % 12 != 0):\n", + " continue\n", + " print(n, \"es divisible por 12\")\n" + ] }, { "attachments": {}, @@ -198,10 +523,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "¿Desea encontrar el siguiente número primo?\n", + "2\n", + "¿Desea encontrar el siguiente número primo?\n", + "3\n", + "¿Desea encontrar el siguiente número primo?\n", + "5\n", + "¿Desea encontrar el siguiente número primo?\n", + "Se finaliza el proceso\n" + ] + } + ], + "source": [ + "n = 1\n", + "sigue = 1\n", + "primo = True\n", + "while (sigue == 1):\n", + " for div in range(2, n):\n", + " if (n % div == 0):\n", + " primo = False\n", + " break\n", + " if (primo):\n", + " print(n)\n", + " print('¿Desea encontrar el siguiente número primo?')\n", + " if (input() != '1'):\n", + " print('Se finaliza el proceso')\n", + " break\n", + " else:\n", + " primo = True\n", + " n += 1" + ] }, { "attachments": {}, @@ -213,10 +572,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "102 es divisible por por 3 y multiplo de 6\n" + ] + } + ], + "source": [ + "tope_rango=301\n", + "n = 99\n", + "while (n < tope_rango):\n", + " n += 1\n", + " if (n % 3 == 0) and (n % 6 == 0):\n", + " print(n, \"es divisible por por 3 y multiplo de 6\")\n", + " break" + ] } ], "metadata": { @@ -238,7 +613,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.8.10" } }, "nbformat": 4, From e1da4de13a09d9827daa08f1620d76f4845be146 Mon Sep 17 00:00:00 2001 From: agus pas Date: Wed, 1 Nov 2023 17:22:02 -0300 Subject: [PATCH 2/3] test --- .../Prep_Course_Homework_05.ipynb | 513 ++++++++++++++---- 1 file changed, 412 insertions(+), 101 deletions(-) diff --git a/M05_estructuradedatos/Prep_Course_Homework_05.ipynb b/M05_estructuradedatos/Prep_Course_Homework_05.ipynb index c71642967..0999f318b 100644 --- a/M05_estructuradedatos/Prep_Course_Homework_05.ipynb +++ b/M05_estructuradedatos/Prep_Course_Homework_05.ipynb @@ -18,10 +18,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'medoza', 'rosario', 'bariloche', 'san juan']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "print(lis1)" + ] }, { "attachments": {}, @@ -33,10 +44,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jujuy\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "print(lis1[1])" + ] }, { "attachments": {}, @@ -48,10 +70,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['jujuy', 'medoza', 'rosario', 'bariloche']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "print(lis1[1:5])" + ] }, { "attachments": {}, @@ -63,10 +96,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print(type(lis1))" + ] }, { "attachments": {}, @@ -78,10 +121,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['jujuy', 'medoza', 'rosario', 'bariloche', 'san juan']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "print(lis1[1:])" + ] }, { "attachments": {}, @@ -93,10 +147,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'medoza', 'rosario', 'bariloche']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "print(lis1[:5])" + ] }, { "attachments": {}, @@ -108,10 +173,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'medoza', 'rosario', 'bariloche', 'san juan', 'buenos aires', 'neuquen']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "lis1.append(\"buenos aires\")\n", + "lis1.append(\"neuquen\")\n", + "print(lis1)" + ] }, { "attachments": {}, @@ -123,10 +201,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\",\"rosario\",\"bariloche\",\"san juan\"]\n", + "lis1.insert(3,'rio negro')\n", + "print(lis1)" + ] }, { "attachments": {}, @@ -138,10 +228,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n" + ] + } + ], + "source": [ + "lis1 = [\"buenos aires\",\"jujuy\",\"medoza\"]\n", + "lis2 = ['rio negro', 'rosario', 'bariloche', 'san juan']\n", + "lis1.extend(lis2)\n", + "print(lis1)" + ] }, { "attachments": {}, @@ -153,10 +256,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n", + "print(lis1.index('rosario'))" + ] }, { "attachments": {}, @@ -168,10 +282,25 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "'pedro' is not in list", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m/home/agustin/agustin/Python-Prep/M05_estructuradedatos/Prep_Course_Homework_05.ipynb Cell 23\u001b[0m line \u001b[0;36m2\n\u001b[1;32m 1\u001b[0m \u001b[39mlist\u001b[39m \u001b[39m=\u001b[39m [\u001b[39m'\u001b[39m\u001b[39mbuenos aires\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mjujuy\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrosario\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mmedoza\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrio negro\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrosario\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mbariloche\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39msan juan\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[0;32m----> 2\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mlist\u001b[39;49m\u001b[39m.\u001b[39;49mindex(\u001b[39m'\u001b[39;49m\u001b[39mpedro\u001b[39;49m\u001b[39m'\u001b[39;49m))\n", + "\u001b[0;31mValueError\u001b[0m: 'pedro' is not in list" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n", + "print(lis1.index('pedro'))" + ] }, { "attachments": {}, @@ -183,10 +312,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n", + "lis1.remove('rosario')\n", + "print(lis1)" + ] }, { "attachments": {}, @@ -198,10 +339,25 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "list.remove(x): x not in list", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m/home/agustin/agustin/Python-Prep/M05_estructuradedatos/Prep_Course_Homework_05.ipynb Cell 27\u001b[0m line \u001b[0;36m2\n\u001b[1;32m 1\u001b[0m \u001b[39mlist\u001b[39m \u001b[39m=\u001b[39m [\u001b[39m'\u001b[39m\u001b[39mbuenos aires\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mjujuy\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrosario\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mmedoza\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrio negro\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrosario\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mbariloche\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39msan juan\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[0;32m----> 2\u001b[0m \u001b[39mlist\u001b[39;49m\u001b[39m.\u001b[39;49mremove(\u001b[39m'\u001b[39;49m\u001b[39mpedro\u001b[39;49m\u001b[39m'\u001b[39;49m)\n", + "\u001b[0;31mValueError\u001b[0m: list.remove(x): x not in list" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n", + "lis1.remove('pedro')" + ] }, { "attachments": {}, @@ -213,10 +369,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "san juan\n", + "['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche']\n" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n", + "ultimo = lis1.pop()\n", + "print(ultimo)\n", + "print(lis1)\n" + ] }, { "attachments": {}, @@ -228,10 +398,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan', 'buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan', 'buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'medoza', 'rio negro', 'rosario', 'bariloche', 'san juan']\n", + "print(lis1*3)" + ] }, { "attachments": {}, @@ -243,10 +424,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)\n" + ] + } + ], + "source": [ + "tup = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)\n", + "print(type(tup))\n", + "print(tup)\n" + ] }, { "attachments": {}, @@ -258,10 +452,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(11, 12, 13, 14, 15, 16)\n" + ] + } + ], + "source": [ + "tup = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)\n", + "print(tup[10:16])" + ] }, { "attachments": {}, @@ -273,10 +478,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n" + ] + } + ], + "source": [ + "tup = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)\n", + "print(20 in tup)\n", + "print(30 in tup)" + ] }, { "attachments": {}, @@ -288,10 +506,26 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Se insertó el elemento París\n" + ] + } + ], + "source": [ + "lis1 = ['buenos aires', 'jujuy', 'rosario', 'mendoza', 'rio negro', 'rosario', 'bariloche', 'san juan', 'mendoza']\n", + "elemento = 'París'\n", + "if (not(elemento in lis1)):\n", + " lis1.append(elemento)\n", + " print('Se insertó el elemento', elemento)\n", + "else:\n", + " print('El elemento', elemento, 'ya existía')" + ] }, { "attachments": {}, @@ -303,10 +537,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "2\n" + ] + } + ], + "source": [ + "print(tup.count(10))\n", + "print(lis1.count('mendoza'))" + ] }, { "attachments": {}, @@ -318,10 +564,26 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'list' object is not callable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m/home/agustin/agustin/Python-Prep/M05_estructuradedatos/Prep_Course_Homework_05.ipynb Cell 43\u001b[0m line \u001b[0;36m2\n\u001b[1;32m 1\u001b[0m tup\u001b[39m=\u001b[39m(\u001b[39m1\u001b[39m,\u001b[39m2\u001b[39m,\u001b[39m3\u001b[39m,\u001b[39m4\u001b[39m,\u001b[39m5\u001b[39m,\u001b[39m6\u001b[39m,\u001b[39m7\u001b[39m,\u001b[39m8\u001b[39m,\u001b[39m9\u001b[39m,\u001b[39m10\u001b[39m,\u001b[39m11\u001b[39m,\u001b[39m12\u001b[39m,\u001b[39m13\u001b[39m,\u001b[39m14\u001b[39m,\u001b[39m15\u001b[39m,\u001b[39m16\u001b[39m,\u001b[39m17\u001b[39m,\u001b[39m18\u001b[39m,\u001b[39m19\u001b[39m,\u001b[39m20\u001b[39m)\n\u001b[0;32m----> 2\u001b[0m lis2\u001b[39m=\u001b[39m\u001b[39mlist\u001b[39;49m(tup)\n\u001b[1;32m 3\u001b[0m \u001b[39mprint\u001b[39m(lis2)\n", + "\u001b[0;31mTypeError\u001b[0m: 'list' object is not callable" + ] + } + ], + "source": [ + "tup=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)\n", + "lis2=list(tup)\n", + "print(lis2)" + ] }, { "attachments": {}, @@ -333,10 +595,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 2 3\n" + ] + } + ], + "source": [ + "v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20 = tup\n", + "print(v1, v2, v3)" + ] }, { "attachments": {}, @@ -348,10 +621,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Ciudad': ['Buenos Aires', 'Brasilia', 'Asunción', 'Montevideo', 'Santiago', 'Lima', 'Caracas', 'Bogotá'], 'País': ['Brasil', 'Paraguay', 'Ecuador', 'Uruguay', 'Chile', 'Perú', 'Venezuela', 'Colombia', 'Méjico', 'Uruguay', 'España', 'Italia', 'Francia'], 'Continente': ['América', 'América', 'América', 'América', 'América', 'América', 'América', 'América', 'América', 'América', 'Europa', 'Europa', 'Europa']}\n" + ] + } + ], + "source": [ + "lis = ['Buenos Aires','Brasilia','Asunción','Montevideo','Santiago','Lima','Caracas','Bogotá']\n", + "dicc = { 'Ciudad': lis, \n", + "'País': ['Brasil','Paraguay','Ecuador','Uruguay','Chile','Perú','Venezuela','Colombia','Méjico','Uruguay','España','Italia','Francia'], \n", + "'Continente' : ['América','América','América','América','América','América','América','América','América','América','Europa','Europa','Europa']}\n", + "print(dicc)" + ] }, { "attachments": {}, @@ -363,10 +650,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dict_keys(['Ciudad', 'País', 'Continente'])\n" + ] + } + ], + "source": [ + "print(dicc.keys())" + ] }, { "attachments": {}, @@ -378,10 +675,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Buenos Aires', 'Brasilia', 'Asunción', 'Montevideo', 'Santiago', 'Lima', 'Caracas', 'Bogotá']\n", + "['Brasil', 'Paraguay', 'Ecuador', 'Uruguay', 'Chile', 'Perú', 'Venezuela', 'Colombia', 'Méjico', 'Uruguay', 'España', 'Italia', 'Francia']\n", + "['América', 'América', 'América', 'América', 'América', 'América', 'América', 'América', 'América', 'América', 'Europa', 'Europa', 'Europa']\n" + ] + } + ], + "source": [ + "print(dicc['Ciudad'])\n", + "print(dicc['País'])\n", + "print(dicc['Continente'])" + ] } ], "metadata": { @@ -403,7 +714,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.8.10" } }, "nbformat": 4, From 2fb496950b3bac828dd14882caf9e881560ae0f8 Mon Sep 17 00:00:00 2001 From: agus pas Date: Thu, 2 Nov 2023 16:19:25 -0300 Subject: [PATCH 3/3] actualizar --- .../Prep_Course_Homework_06.ipynb | 480 +++++++++++++++--- 1 file changed, 415 insertions(+), 65 deletions(-) diff --git a/M06_iterablesiteradores/Prep_Course_Homework_06.ipynb b/M06_iterablesiteradores/Prep_Course_Homework_06.ipynb index 75d6c18b1..bbe7d035e 100644 --- a/M06_iterablesiteradores/Prep_Course_Homework_06.ipynb +++ b/M06_iterablesiteradores/Prep_Course_Homework_06.ipynb @@ -18,10 +18,26 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]\n" + ] + } + ], + "source": [ + "lis1 = []\n", + "n=-15\n", + "while n<0:\n", + " lis1.append(n)\n", + " n += 1\n", + "print(lis1)\n", + " " + ] }, { "attachments": {}, @@ -33,10 +49,30 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-14\n", + "-12\n", + "-10\n", + "-8\n", + "-6\n", + "-4\n", + "-2\n" + ] + } + ], + "source": [ + "n=0\n", + "while n\n", + "Lista: ['H', 'o', 'l', 'a', ' ', 'M', 'u', 'n', 'd', 'o', '.', ' ', 'E', 's', 't', 'o', ' ', 'e', 's', ' ', 'u', 'n', 'a', ' ', 'p', 'r', 'a', 'c', 't', 'i', 'c', 'a', ' ', 'd', 'e', 'l', ' ', 'l', 'e', 'n', 'g', 'u', 'a', 'j', 'e', ' ', 'd', 'e', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm', 'a', 'c', 'i', 'ó', 'n', ' ', 'P', 'y', 't', 'h', 'o', 'n']\n", + "\n", + "H\n", + " o\n", + " l\n", + " a\n", + " \n", + " M\n", + " u\n", + " n\n", + " d\n", + " o\n", + " .\n", + " \n", + " E\n", + " s\n", + " t\n", + " o\n", + " \n", + " e\n", + " s\n", + " \n", + " u\n", + " n\n", + " a\n", + " \n", + " p\n", + " r\n", + " a\n", + " c\n", + " t\n", + " i\n", + " c\n", + " a\n", + " \n", + " d\n", + " e\n", + " l\n", + " \n", + " l\n", + " e\n", + " n\n", + " g\n", + " u\n", + " a\n", + " j\n", + " e\n", + " \n", + " d\n", + " e\n", + " \n", + " p\n", + " r\n", + " o\n", + " g\n", + " r\n", + " a\n", + " m\n", + " a\n", + " c\n", + " i\n", + " ó\n", + " n\n", + " \n", + " P\n", + " y\n", + " t\n", + " h\n", + " o\n", + " n\n", + " " + ] + } + ], + "source": [ + "cadena = 'Hola Mundo. Esto es una practica del lenguaje de programación Python'\n", + "print(type(cadena))\n", + "lis1=list(cadena)\n", + "print(\"Lista: \",lis1)\n", + "print(type(lis1))\n", + "\n", + "rec = iter(lis1)\n", + "lar = len(lis1)\n", + "\n", + "for i in range(0, lar):\n", + " print(next(rec))\n", + " print(end=\" \")\n" + ] }, { "attachments": {}, @@ -210,10 +493,30 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "(('H', 'F'), ('o', 'I'), ('l', 'N'))\n", + "\n" + ] + } + ], + "source": [ + "lis2= ['H', 'o', 'l', 'a', ' ', 'M', 'u', 'n', 'd', 'o']\n", + "lis3= ['F', 'I', 'N']\n", + "lis4= zip(lis2,lis3)\n", + "print(lis4)\n", + "print(type(lis4))\n", + "tup1=tuple(lis4)\n", + "print(tup1)\n", + "print(type(tup1))\n" + ] }, { "attachments": {}, @@ -226,10 +529,26 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[21, 35, 42, 56, 63, 84, 91]\n" + ] + } + ], + "source": [ + "lis5 = [18,21,29,32,35,42,56,60,63,71,84,90,91,100]\n", + "lis6 = []\n", + "largo=len(lis5)\n", + "for i in range(0, largo):\n", + " if lis5[i]%7 == 0:\n", + " lis6.append(lis5[i])\n", + "print(lis6)\n" + ] }, { "attachments": {}, @@ -242,10 +561,28 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12\n" + ] + } + ], + "source": [ + "lis7 = [[1,2,3,4],'rojo','verde',[True,False,False],['uno','dos','tres']]\n", + "type(lis7)\n", + "cant=0\n", + "for elemento in lis7:\n", + " if type(elemento)==list:\n", + " cant+=len(elemento)\n", + " else:\n", + " cant+=1\n", + "print(cant)" + ] }, { "attachments": {}, @@ -257,10 +594,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[1, 2, 3, 4], ['rojo'], ['verde'], [True, False, False], ['uno', 'dos', 'tres']]\n" + ] + } + ], + "source": [ + "for indice, elemento in enumerate(lis7):\n", + " if type(elemento) != list:\n", + " lis7[indice]=[elemento]\n", + "print(lis7)\n" + ] } ], "metadata": { @@ -282,7 +632,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.8.10" } }, "nbformat": 4,