diff --git a/M03_variablesydatos/Prep_Course_Homework_03.ipynb b/M03_variablesydatos/Prep_Course_Homework_03.ipynb index b4d68b08b..8821a2e58 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": 124, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "14\n" + ] + } + ], + "source": [ + "y = 14\n", + "print(y)" + ] }, { "attachments": {}, @@ -33,10 +44,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 125, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print(type(8.5))\n" + ] }, { "attachments": {}, @@ -48,10 +69,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 126, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(y)" + ] }, { "attachments": {}, @@ -63,10 +97,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 127, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rodrigo Perez Aller\n" + ] + } + ], + "source": [ + "mi_name = \"Rodrigo Perez Aller\"\n", + "type(mi_name)\n", + "print(mi_name)\n" + ] }, { "attachments": {}, @@ -78,10 +124,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 128, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3+8j)\n" + ] + } + ], + "source": [ + "numero_complejo= 3+8j\n", + "print(numero_complejo)" + ] }, { "attachments": {}, @@ -93,10 +150,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 129, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "complex" + ] + }, + "execution_count": 129, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(numero_complejo)" + ] }, { "attachments": {}, @@ -108,10 +178,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 130, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.1416\n" + ] + } + ], + "source": [ + "pi=3.1416\n", + "print(pi)" + ] }, { "attachments": {}, @@ -123,10 +204,30 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 131, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(False, str, bool)" + ] + }, + "execution_count": 131, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "var1 = 'True'\n", + "var2 = True\n", + "valor_cadena = 'True'\n", + "valor_booleano = True\n", + "son_iguales = (valor_cadena == valor_booleano)\n", + "tipo_valor_cadena = type(valor_cadena)\n", + "tipo_valor_booleano = type(valor_booleano)\n", + "son_iguales, tipo_valor_cadena, tipo_valor_booleano\n" + ] }, { "attachments": {}, @@ -138,10 +239,28 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 132, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False \n", + "True True\n", + " \n", + " \n", + "False \n" + ] + } + ], + "source": [ + "print(son_iguales, tipo_valor_cadena, tipo_valor_booleano)\n", + "print(var1, var2)\n", + "print(type(var1), type(var2))\n", + "print(type(valor_cadena), type(valor_booleano))\n", + "print(son_iguales, tipo_valor_cadena, tipo_valor_booleano)" + ] }, { "attachments": {}, @@ -153,10 +272,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 133, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "y = 18+11.4" + ] }, { "attachments": {}, @@ -168,10 +289,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 134, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(7+14j)\n" + ] + } + ], + "source": [ + "y = 2+5j\n", + "w = 5+9j\n", + "print(y+w)\n" + ] }, { "attachments": {}, @@ -183,10 +316,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 135, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(6.61+9j)\n" + ] + } + ], + "source": [ + "y= w +1.61\n", + "print(y)" + ] }, { "attachments": {}, @@ -198,10 +342,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 136, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "30\n" + ] + } + ], + "source": [ + "print(5*6)" + ] }, { "attachments": {}, @@ -213,10 +367,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 137, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "15625\n" + ] + } + ], + "source": [ + "print(5**6)" + ] }, { "attachments": {}, @@ -228,10 +392,32 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 138, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7.428571428571429\n" + ] + }, + { + "data": { + "text/plain": [ + "7.43" + ] + }, + "execution_count": 138, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "p = 52/7\n", + "print(p)\n", + "round(p, 2)" + ] }, { "attachments": {}, @@ -243,10 +429,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 139, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "print(52//7)" + ] }, { "attachments": {}, @@ -258,10 +454,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 140, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 140, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "27%4" + ] }, { "attachments": {}, @@ -273,10 +482,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 141, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "27" + ] + }, + "execution_count": 141, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "6*4+3" + ] }, { "attachments": {}, @@ -288,10 +510,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 142, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Estados Unidos\n" + ] + } + ], + "source": [ + "var1 = \"Estados\"\n", + "var2 = \"Unidos\"\n", + "print(var1, var2)" + ] }, { "attachments": {}, @@ -303,10 +537,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 143, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 143, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2==\"2\"" + ] }, { "attachments": {}, @@ -318,10 +565,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 144, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 144, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "2== int(\"2\")" + ] }, { "attachments": {}, @@ -333,10 +593,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 145, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'float' object is not callable", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[145], line 1\u001b[0m\n\u001b[1;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\n", + "\u001b[1;31mTypeError\u001b[0m: 'float' object is not callable" + ] + } + ], + "source": [ + "a = float(\"3,8\")" + ] }, { "attachments": {}, @@ -350,8 +624,20 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-4\n" + ] + } + ], + "source": [ + "a = -3\n", + "a -= 1\n", + "print(a)" + ] }, { "attachments": {}, @@ -365,8 +651,21 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1<<2" + ] }, { "attachments": {}, @@ -380,8 +679,60 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], - "source": [] + "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)", + "Cell \u001b[1;32mIn[56], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;241;43m2\u001b[39;49m\u001b[38;5;241;43m+\u001b[39;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[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" + ] + } + ], + "source": [ + "2+\"2\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], + "source": [ + "int(2) + int(\"2\")\n", + "print(int(2) + int(\"2\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'22'" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "str(2) + str(\"2\")" + ] }, { "attachments": {}, @@ -391,6 +742,25 @@ "26) Realizar una operación válida entre valores de tipo entero y string" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "este texto se repiteeste texto se repiteeste texto se repite3veces\n" + ] + } + ], + "source": [ + "var1 = \"este texto se repite\"\n", + "var2 = 3\n", + "print(var1*var2+str(var2) + \"veces\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -418,7 +788,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.12.1" } }, "nbformat": 4,