diff --git a/1_variables_operators.ipynb b/1_variables_operators.ipynb index 5d0ce83..e33cf3f 100644 --- a/1_variables_operators.ipynb +++ b/1_variables_operators.ipynb @@ -1308,7 +1308,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -1327,10 +1327,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " \n" + ] + } + ], + "source": [ + "print(type(x1), type(x2), type(x3), type(x4), type(x5), type(x6))" + ] }, { "cell_type": "markdown", @@ -1341,10 +1351,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# x1 is a float and x3 is a string" + ] }, { "cell_type": "markdown", @@ -1355,10 +1367,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "TypeError", + "evalue": "unsupported operand type(s) for -: 'float' 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[55], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mx1\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43mx3\u001b[49m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m# This will give an error because you cannot subtract a string from an integer\u001b[39;00m\n", + "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'float' and 'str'" + ] + } + ], + "source": [ + "x1-x3\n", + "# This will give an error because you cannot subtract a string from an integer" + ] }, { "cell_type": "markdown", @@ -1369,10 +1396,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 56, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# x4 is a boolean and x5 is a string" + ] }, { "cell_type": "markdown", @@ -1383,10 +1412,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "TypeError", + "evalue": "unsupported operand type(s) for -: 'str' and 'bool'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[57], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mx5\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43mx4\u001b[49m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m# This will give an error because you cannot subtract a string from a boolean\u001b[39;00m\n", + "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'str' and 'bool'" + ] + } + ], + "source": [ + "x5-x4\n", + "# This will give an error because you cannot subtract a string from a boolean" + ] }, { "cell_type": "markdown", @@ -1427,10 +1471,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3, 7\n" + ] + }, + { + "data": { + "text/plain": [ + "(str, str)" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1 = input(\"Please enter an integer number: \")\n", + "x2 = input(\"Please enter another integer number: \")\n", + "print(x1 + \", \" + x2)\n", + "type(x1), type(x2)" + ] }, { "cell_type": "markdown", @@ -1441,10 +1508,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 59, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "\n", + "7\n", + "\n" + ] + } + ], + "source": [ + "x1int = int(x1)\n", + "x2int = int(x2)\n", + "print(x1int)\n", + "print(type(x1int))\n", + "print(x2int)\n", + "print(type(x2int))" + ] }, { "cell_type": "markdown", @@ -1466,10 +1551,83 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1 == x2" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1 > x2" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1 < x2" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1 != x2" + ] }, { "cell_type": "markdown", @@ -1482,10 +1640,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Good Evening, Leon Bittis!\n" + ] + } + ], + "source": [ + "first_name = input(\"Please enter your first name: \")\n", + "last_name = input(\"Please enter your last name: \")\n", + "print(\"Good Evening, \" + first_name + \" \" + last_name + \"!\")" + ] }, { "cell_type": "markdown", @@ -1496,7 +1666,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -1544,9 +1714,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x is y" ] @@ -1568,9 +1749,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "x is not y" ] @@ -1600,7 +1792,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -1625,9 +1817,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a in b" ] @@ -1649,9 +1852,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a not in b" ] @@ -1666,7 +1880,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -1680,7 +1894,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.2" } }, "nbformat": 4,