From 4bcd94d0c7c80b68dcd42b3cba9d9556d99dacc8 Mon Sep 17 00:00:00 2001 From: M0RNINGSTAR30 <162505072+M0RNINGSTAR30@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:39:49 -0600 Subject: [PATCH] Update Prep_Course_Homework_03.ipynb --- .../Prep_Course_Homework_03.ipynb | 497 ++++++++++++++---- 1 file changed, 396 insertions(+), 101 deletions(-) diff --git a/M03_variablesydatos/Prep_Course_Homework_03.ipynb b/M03_variablesydatos/Prep_Course_Homework_03.ipynb index b4d68b08b..785f673a0 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": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], + "source": [ + "x = 4\n", + "print (x)" + ] }, { "attachments": {}, @@ -33,10 +44,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8.5\n" + ] + } + ], + "source": [ + "a = 8.5\n", + "print (a)" + ] }, { "attachments": {}, @@ -48,10 +70,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], + "source": [ + "print (x)" + ] }, { "attachments": {}, @@ -63,10 +95,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tú nombre es: Benjamín\n" + ] + } + ], + "source": [ + "name = \"Benjamín\"\n", + "print (\"Tú nombre es: \" + name)" + ] }, { "attachments": {}, @@ -78,10 +121,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "z = 3\n", + "b = 2\n", + "c = 2\n", + "d = (z+b+c)\n", + "print (d)\n" + ] }, { "attachments": {}, @@ -93,10 +150,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "print (d)" + ] }, { "attachments": {}, @@ -108,10 +175,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print (type(d))" + ] }, { "attachments": {}, @@ -123,10 +200,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "verdadero = True\n", + "cierto = 'True'" + ] }, { "attachments": {}, @@ -138,10 +218,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "print (type(verdadero))\n", + "print (type(cierto))" + ] }, { "attachments": {}, @@ -153,10 +245,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5.5\n" + ] + } + ], + "source": [ + "f= (3 + 2.5)\n", + "print (f)" + ] }, { "attachments": {}, @@ -168,10 +271,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "50.5\n" + ] + } + ], + "source": [ + "g= (45 + 3 + 2.5)\n", + "print (g)" + ] }, { "attachments": {}, @@ -183,10 +297,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "32\n" + ] + } + ], + "source": [ + "j= (1+2+3+4+5)\n", + "k= (12 + 3 + 2)\n", + "m= (j + k)\n", + "print (m)" + ] }, { "attachments": {}, @@ -198,10 +325,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "384\n" + ] + } + ], + "source": [ + "q = (32 * 12)\n", + "print (q)" + ] }, { "attachments": {}, @@ -213,10 +351,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], + "source": [ + "w = (2^8)\n", + "print (w)" + ] }, { "attachments": {}, @@ -228,10 +377,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5.0\n" + ] + } + ], + "source": [ + "e = (25 / 5)\n", + "print (e)" + ] }, { "attachments": {}, @@ -243,10 +403,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + } + ], + "source": [ + "print (round(e))" + ] }, { "attachments": {}, @@ -258,10 +428,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "t= (27 % 4)\n", + "print (t)" + ] }, { "attachments": {}, @@ -273,10 +454,25 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "27\n", + "27\n" + ] + } + ], + "source": [ + "problema_a = (4 * 4 * 4 * 4 / e -4 -4 -4 -4 -4 -4)\n", + "problema_b = (4 * 4 + 4 + 4 + t)\n", + "\n", + "print (round(problema_a))\n", + "print (problema_b)" + ] }, { "attachments": {}, @@ -288,10 +484,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hola tonotos\n" + ] + } + ], + "source": [ + "variable_a = \"Hola \"\n", + "variable_b = \"tonotos\"\n", + "variable_c = (variable_a + variable_b)\n", + "print (variable_c)" + ] }, { "attachments": {}, @@ -303,10 +512,25 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b = \"2\"\n", + "n = 2\n", + "eval(\"b == n\")" + ] }, { "attachments": {}, @@ -318,10 +542,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "resultado_20 = int(b) == n\n", + "print (resultado_20)" + ] }, { "attachments": {}, @@ -333,10 +568,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.8\n" + ] + } + ], + "source": [ + "a = float(\"3.8\")\n", + "print (a)" + ] }, { "attachments": {}, @@ -348,10 +594,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], + "source": [ + "variable_d = 3\n", + "variable_d -= 1\n", + "print (variable_d)" + ] }, { "attachments": {}, @@ -363,10 +621,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "ad= 1<<2\n", + "print= (ad)" + ] }, { "attachments": {}, @@ -378,10 +639,27 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "unsupported operand type(s) for +: 'int' and 'str'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Benja\\OneDrive\\Escritorio\\Python-Prep\\M03_variablesydatos\\Prep_Course_Homework_03.ipynb Cell 51\u001b[0m line \u001b[0;36m3\n\u001b[0;32m 1\u001b[0m \u001b[39m#No está permitido porqué a pesar que son dos numeros iguales no son el mismo tipo de dato, ne dado caso lo mejor seria convertirlos a un mismo dato:\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m bc \u001b[39m=\u001b[39m \u001b[39m2\u001b[39;49m \u001b[39m+\u001b[39;49m \u001b[39mint\u001b[39;49m(\u001b[39m\"\u001b[39;49m\u001b[39m2\u001b[39;49m\u001b[39m\"\u001b[39;49m) \u001b[39m+\u001b[39;49m \u001b[39mstr\u001b[39;49m(\u001b[39m\"\u001b[39;49m\u001b[39m2\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[0;32m 4\u001b[0m \u001b[39mprint\u001b[39m (bc)\n", + "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" + ] + } + ], + "source": [ + "#No está permitido porqué a pesar que son dos numeros iguales no son el mismo tipo de dato, ne dado caso lo mejor seria convertirlos a un mismo dato:\n", + "\n", + "bc = 2 + int(\"2\") + str(\"2\")\n", + "print (bc)" + ] }, { "attachments": {}, @@ -393,10 +671,27 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 113, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "invalid literal for int() with base 10: 'Hola tonotos'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Benja\\OneDrive\\Escritorio\\Python-Prep\\M03_variablesydatos\\Prep_Course_Homework_03.ipynb Cell 53\u001b[0m line \u001b[0;36m3\n\u001b[0;32m 1\u001b[0m var1\u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mHola tonotos\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 2\u001b[0m var2\u001b[39m=\u001b[39m \u001b[39m2\u001b[39m\n\u001b[1;32m----> 3\u001b[0m var3\u001b[39m=\u001b[39m \u001b[39mint\u001b[39;49m(var1) \u001b[39m*\u001b[39m var2\n\u001b[0;32m 4\u001b[0m \u001b[39mprint\u001b[39m (var3)\n", + "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'Hola tonotos'" + ] + } + ], + "source": [ + "var1= \"Hola tonotos\"\n", + "var2= 2\n", + "var3= int(var1) * var2\n", + "print (var3)" + ] } ], "metadata": { @@ -418,7 +713,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.12.2" } }, "nbformat": 4,