From b2d8e66a42a506ffd87550a2b57ef199f3cc6007 Mon Sep 17 00:00:00 2001 From: JVelascoEspinoza Date: Sat, 20 Jan 2024 10:57:02 -0500 Subject: [PATCH 1/5] enter --- .DS_Store | Bin 0 -> 6148 bytes .../Prep_Course_Homework_03.ipynb | 446 ++++++++++++++---- 2 files changed, 351 insertions(+), 95 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6a8fa73ff4a731a84a26d20da4d1189efcca1270 GIT binary patch literal 6148 zcmeHKO>fgc5Pe&6C?KLDir@f}e?dj~=H`~{JP6Yb9KdgsmVo3S?wz#Xin17HWhHj8xc8mkLL&s8>LD~$B1oiJYI zWj4vn3Ht(!5*dgL{M!uZ-Rg6#q| z+e@|zcSFK3P2vK0MO5E|R<7LAqr~kBD?i?-lWm zFhS0BE%6ys_G)4;+v{;(eh=kzTorj)%xTT9AH46!^!ILKLl8T&!qcvliPzyJQzzT1PWlcZ`dt#%fJF*`IT|PBcKB2EF#0BNXRNslBNSR}2?!4$hnNc^c-gz4qpC z=9xIbvkNyA7cL$yvFUKB*RhTaL8)Sym-UVF_EO8g^WG{h=0@K+i52|pwB AMgRZ+ literal 0 HcmV?d00001 diff --git a/M03_variablesydatos/Prep_Course_Homework_03.ipynb b/M03_variablesydatos/Prep_Course_Homework_03.ipynb index b4d68b08b..b04e6f33c 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": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], + "source": [ + "numero_entero= 4\n", + "print(numero_entero)" + ] }, { "attachments": {}, @@ -33,10 +44,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + } + ], + "source": [ + "print(int(8.5))" + ] }, { "attachments": {}, @@ -48,10 +69,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print(type(numero_entero))" + ] }, { "attachments": {}, @@ -63,10 +94,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "mi_nombre= 'Josué Velasco'" + ] }, { "attachments": {}, @@ -78,10 +111,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "numero_complejo=3+3j" + ] }, { "attachments": {}, @@ -93,10 +128,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print(type(numero_complejo))" + ] }, { "attachments": {}, @@ -108,10 +153,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "pi=3.1415" + ] }, { "attachments": {}, @@ -123,10 +170,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "variable1=\"True\"\n", + "variable2=True" + ] }, { "attachments": {}, @@ -138,10 +188,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "la variable1 es y la variable2 es \n" + ] + } + ], + "source": [ + "print('la variable1 es', type(variable1), 'y la variable2 es' ,type(variable2))" + ] }, { "attachments": {}, @@ -153,10 +213,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "entero_decimal= 4+3.2" + ] }, { "attachments": {}, @@ -168,10 +230,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8j\n" + ] + } + ], + "source": [ + "a=4j+4j\n", + "print(a)" + ] }, { "attachments": {}, @@ -183,10 +256,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(12+12j)\n" + ] + } + ], + "source": [ + "b=4+4j\n", + "c=8+8j\n", + "print(b+c)" + ] }, { "attachments": {}, @@ -198,10 +283,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6\n" + ] + } + ], + "source": [ + "d=3*2\n", + "print(d)" + ] }, { "attachments": {}, @@ -213,10 +309,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "256\n" + ] + } + ], + "source": [ + "e=2**8\n", + "print(e)" + ] }, { "attachments": {}, @@ -228,10 +335,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6.75\n" + ] + } + ], + "source": [ + "f=27/4\n", + "print(f)" + ] }, { "attachments": {}, @@ -243,10 +361,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6\n" + ] + } + ], + "source": [ + "print(int(f))" + ] }, { "attachments": {}, @@ -258,10 +386,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "print(24%7)" + ] }, { "attachments": {}, @@ -273,10 +411,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "28" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "4*6+4" + ] }, { "attachments": {}, @@ -288,10 +439,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Hola mundo'" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'Hola' + ' mundo'" + ] }, { "attachments": {}, @@ -303,10 +467,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "'a' es de tipo mientras que a es tipo \n" + ] + } + ], + "source": [ + "print(bool(\"2\" == 2))\n", + "print(\"'a' es de tipo\", type('2'), \"mientras que a es tipo\", type(2))" + ] }, { "attachments": {}, @@ -318,10 +494,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"2\" == str(2)" + ] }, { "attachments": {}, @@ -333,10 +522,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "could not convert string to float: '3,8'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[77], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mfloat\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m3,8\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m#Ya es float\u001b[39;00m\n", + "\u001b[0;31mValueError\u001b[0m: could not convert string to float: '3,8'" + ] + } + ], + "source": [ + "a = float('3,8') #Ya es float" + ] }, { "attachments": {}, @@ -348,10 +551,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 84, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], + "source": [ + "g = 3\n", + "g -= 1\n", + "print (g)" + ] }, { "attachments": {}, @@ -363,10 +578,25 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n", + "El número 1 es desplazado dos posiciones y se multiplica con 2 a la potencia de 2\n", + "El Sistema binario solo utiliza dos cifras para representar todos sus números, el 0 y el 1\n" + ] + } + ], + "source": [ + "h = (1 << 2)\n", + "print (h)\n", + "print (\"El número 1 es desplazado dos posiciones y se multiplica con 2 a la potencia de 2\")\n", + "print (\"El Sistema binario solo utiliza dos cifras para representar todos sus números, el 0 y el 1\")" + ] }, { "attachments": {}, @@ -378,10 +608,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "unsupported operand type(s) for +: 'int' and 'str'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[94], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;241;43m2\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m2\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\n", + "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" + ] + } + ], + "source": [ + "2 + '2'" + ] }, { "attachments": {}, @@ -393,10 +637,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tarea tarea tarea \n" + ] + } + ], + "source": [ + "i = 3\n", + "j = \"tarea \"\n", + "print (i * j)" + ] } ], "metadata": { @@ -418,7 +674,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.12.1" } }, "nbformat": 4, From 46d60e03ae1c4ab8c07ea5b4fcbce72389edd23f Mon Sep 17 00:00:00 2001 From: JVelascoEspinoza Date: Sat, 20 Jan 2024 18:46:17 -0500 Subject: [PATCH 2/5] Josue Velasco PC Local --- M04_flujosdecontrol/Prep_Course_Homework_04.ipynb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb index 8b5ecb46c..04af40e64 100644 --- a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb +++ b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb @@ -18,10 +18,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a = 4" + ] }, { "attachments": {}, @@ -238,7 +240,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.12.1" } }, "nbformat": 4, From b81d11392eb074f7ca4f2cdea2c066dfd190d144 Mon Sep 17 00:00:00 2001 From: JVelascoEspinoza Date: Mon, 5 Feb 2024 19:07:40 -0500 Subject: [PATCH 3/5] Lunes 5 de Febrero 2024 --- .../Prep_Course_Homework_04.ipynb | 80 ++++++++++++++++--- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb index 04af40e64..31a4bb0b3 100644 --- a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb +++ b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb @@ -18,11 +18,25 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "La variable 8 es mayor a 0\n" + ] + } + ], "source": [ - "a = 4" + "a = 8\n", + "if (a > 0):\n", + " print (f\"La variable {a} es mayor a 0\")\n", + "elif (a < 0):\n", + " print (f\"La variable {a} es menor a 0\")\n", + "else:\n", + " print (f\"La variable {a} es igual a 0\")" ] }, { @@ -35,10 +49,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "La variables 'arriba' y '8' son de diferente tipo de dato\n" + ] + } + ], + "source": [ + "a = 'arriba'\n", + "b = 8\n", + "if (type(a) == type(b)):\n", + " print (f\"La variables '{a}' y '{b}' son del mismo tipo de dato\")\n", + "else:\n", + " print (f\"La variables '{a}' y '{b}' son de diferente tipo de dato\")" + ] }, { "attachments": {}, @@ -50,10 +79,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "El número 1 es impar\n", + "El número 2 es par\n", + "El número 3 es impar\n", + "El número 4 es par\n", + "El número 5 es impar\n", + "El número 6 es par\n", + "El número 7 es impar\n", + "El número 8 es par\n", + "El número 9 es impar\n", + "El número 10 es par\n", + "El número 11 es impar\n", + "El número 12 es par\n", + "El número 13 es impar\n", + "El número 14 es par\n", + "El número 15 es impar\n", + "El número 16 es par\n", + "El número 17 es impar\n", + "El número 18 es par\n", + "El número 19 es impar\n", + "El número 20 es par\n" + ] + } + ], + "source": [ + "for c in range(1, 21):\n", + " if c % 2 == 0:\n", + " print ('El número ', str(c), ' es par')\n", + " else:\n", + " print ('El número ', str(c), ' es impar')" + ] }, { "attachments": {}, From b816e8fc12ed787410c2bc3b4cce6a9f894c9167 Mon Sep 17 00:00:00 2001 From: JVelascoEspinoza Date: Wed, 7 Feb 2024 17:21:05 -0500 Subject: [PATCH 4/5] jueves 7 febrero --- .../Prep_Course_Homework_04.ipynb | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb index 31a4bb0b3..94e78197f 100644 --- a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb +++ b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb @@ -127,10 +127,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 elevado a la potencia 3 es = 0\n", + "1 elevado a la potencia 3 es = 1\n", + "2 elevado a la potencia 3 es = 8\n", + "3 elevado a la potencia 3 es = 27\n", + "4 elevado a la potencia 3 es = 64\n" + ] + } + ], + "source": [ + "for d in range(0,5):\n", + " print(str(d), \"elevado a la potencia 3 es =\", str(d**3))" + ] }, { "attachments": {}, @@ -145,7 +160,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "d = 5\n" + ] }, { "attachments": {}, From 13820d56b482093f2ca6e1615107a4f875e42e8a Mon Sep 17 00:00:00 2001 From: JVelascoEspinoza Date: Wed, 7 Feb 2024 17:21:42 -0500 Subject: [PATCH 5/5] =?UTF-8?q?mi=C3=A9rcoles=207=20febrero?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Prep_Course_Homework_04.ipynb | 196 ++++++++++++++++-- 1 file changed, 178 insertions(+), 18 deletions(-) diff --git a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb index 94e78197f..6def60c11 100644 --- a/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb +++ b/M04_flujosdecontrol/Prep_Course_Homework_04.ipynb @@ -157,11 +157,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], "source": [ - "d = 5\n" + "d = 5\n", + "for e in range(0, d):\n", + " pass\n", + "print (e)" ] }, { @@ -174,10 +185,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "el factorial es 120\n" + ] + } + ], + "source": [ + "f = 5\n", + "if (type(f) == int):\n", + " if (f > 0):\n", + " factorial = f\n", + " while (f > 2):\n", + " f = f - 1\n", + " factorial = factorial * f\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 número entero')" + ] }, { "attachments": {}, @@ -189,10 +221,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iteración del ciclo while: 0\n", + "Iteración del ciclo for: 0\n", + "Iteración del ciclo for: 1\n", + "Iteración del ciclo for: 2\n", + "Iteración del ciclo while: 1\n", + "Iteración del ciclo for: 0\n", + "Iteración del ciclo for: 1\n", + "Iteración del ciclo for: 2\n", + "Iteración del ciclo while: 2\n", + "Iteración del ciclo for: 0\n", + "Iteración del ciclo for: 1\n", + "Iteración del ciclo for: 2\n" + ] + } + ], + "source": [ + "contador_while = 0\n", + "while contador_while < 3: # Ciclo while para contar hasta 3\n", + " print(\"Iteración del ciclo while:\", contador_while)\n", + " \n", + " for g in range(3): # Ciclo for para contar hasta 3 en cada iteración del ciclo while\n", + " print(\"Iteración del ciclo for:\", g)\n", + " \n", + " contador_while += 1" + ] }, { "attachments": {}, @@ -204,10 +264,45 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iteración del ciclo for: 1\n", + "Iteración del ciclo while dentro del ciclo for: 1\n", + "Iteración del ciclo for: 2\n", + "Iteración del ciclo while dentro del ciclo for: 1\n", + "Iteración del ciclo while dentro del ciclo for: 2\n", + "Iteración del ciclo for: 3\n", + "Iteración del ciclo while dentro del ciclo for: 1\n", + "Iteración del ciclo while dentro del ciclo for: 2\n", + "Iteración del ciclo while dentro del ciclo for: 3\n", + "Iteración del ciclo for: 4\n", + "Iteración del ciclo while dentro del ciclo for: 1\n", + "Iteración del ciclo while dentro del ciclo for: 2\n", + "Iteración del ciclo while dentro del ciclo for: 3\n", + "Iteración del ciclo while dentro del ciclo for: 4\n", + "Iteración del ciclo for: 5\n", + "Iteración del ciclo while dentro del ciclo for: 1\n", + "Iteración del ciclo while dentro del ciclo for: 2\n", + "Iteración del ciclo while dentro del ciclo for: 3\n", + "Iteración del ciclo while dentro del ciclo for: 4\n", + "Iteración del ciclo while dentro del ciclo for: 5\n" + ] + } + ], + "source": [ + "for i in range(1, 6): # Ciclo for para iterar sobre una lista de números del 1 al 5\n", + " print(\"Iteración del ciclo for:\", i)\n", + " \n", + " contador_while = 1\n", + " while contador_while <= i: # Ciclo while para contar desde 1 hasta el número actual del ciclo for\n", + " print(\"Iteración del ciclo while dentro del ciclo for:\", contador_while)\n", + " contador_while += 1\n" + ] }, { "attachments": {}, @@ -219,10 +314,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "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 = 30\n", + "n = 0\n", + "primo = True\n", + "while (n < tope):\n", + " for dividir in range(2, n):\n", + " if (n % dividir == 0):\n", + " primo = False\n", + " if (primo):\n", + " print(n)\n", + " else:\n", + " primo = True\n", + " n += 1\n" + ] }, { "attachments": {}, @@ -234,10 +361,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "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 = 30\n", + "n = 0\n", + "primo = True\n", + "while (n < tope):\n", + " for dividir in range(2, n):\n", + " if (n % dividir == 0):\n", + " primo = False\n", + " break\n", + " if (primo):\n", + " print(n)\n", + " else:\n", + " primo = True\n", + " n += 1" + ] }, { "attachments": {},