diff --git a/Intro Python - Data types 1.ipynb b/Intro Python - Data types 1.ipynb index 2b129c3..3ad16f1 100644 --- a/Intro Python - Data types 1.ipynb +++ b/Intro Python - Data types 1.ipynb @@ -50,9 +50,37 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Zen of Python, by Tim Peters\n", + "\n", + "Beautiful is better than ugly.\n", + "Explicit is better than implicit.\n", + "Simple is better than complex.\n", + "Complex is better than complicated.\n", + "Flat is better than nested.\n", + "Sparse is better than dense.\n", + "Readability counts.\n", + "Special cases aren't special enough to break the rules.\n", + "Although practicality beats purity.\n", + "Errors should never pass silently.\n", + "Unless explicitly silenced.\n", + "In the face of ambiguity, refuse the temptation to guess.\n", + "There should be one-- and preferably only one --obvious way to do it.\n", + "Although that way may not be obvious at first unless you're Dutch.\n", + "Now is better than never.\n", + "Although never is often better than *right* now.\n", + "If the implementation is hard to explain, it's a bad idea.\n", + "If the implementation is easy to explain, it may be a good idea.\n", + "Namespaces are one honking great idea -- let's do more of those!\n" + ] + } + ], "source": [ "import this" ] @@ -96,24 +124,47 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello World\n" + ] + } + ], "source": [ "print (\"Hello World\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Second line\n" + ] + } + ], "source": [ "print (\"Second line\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Changed the cell to a Markdown and then enter to confirm" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -137,9 +188,16 @@ "print(\"Now it is a code cell :)\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Testing a markdown cell" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -167,12 +225,10 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": { "scrolled": true }, - "outputs": [], "source": [ "# Header 1\n", "## Header 2\n", @@ -188,6 +244,36 @@ "this is a new paragraph" ] }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (2994576558.py, line 7)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m Cell \u001b[0;32mIn[15], line 7\u001b[0;36m\u001b[0m\n\u001b[0;31m **bold**\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "# I want to see this code\n", + "# Header 1\n", + "## Header 2\n", + "### Header 3\n", + "#### Header 4\n", + "\n", + "**bold**\n", + "\n", + "*italic*\n", + "\n", + "a blank line is a paragraph\n", + "\n", + "this is a new paragraph" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -235,7 +321,7 @@ "metadata": {}, "source": [ "**Link**\n", - "[This is google](https://www.google.es)" + "[This is google](https://www.google.com.ar)" ] }, { @@ -294,11 +380,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ - "whole_number = 4" + "an_integer = 4" ] }, { @@ -310,13 +396,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "whole_number" + "an_integer" ] }, { @@ -328,13 +425,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], "source": [ - "print(whole_number)" + "print(an_integer)" ] }, { @@ -346,9 +451,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "20" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a = 10\n", "b = 20\n", @@ -365,11 +481,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + }, + { + "data": { + "text/plain": [ + "20" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a = 10\n", "b = 20\n", @@ -386,9 +520,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(a)" ] @@ -429,11 +574,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "a = 12.34" + "a = 12.34\n", + "type(a)" ] }, { @@ -445,9 +602,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12.34\n" + ] + } + ], "source": [ "print(a)" ] @@ -461,16 +626,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(a)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -488,13 +664,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# type(b)" + "type(b)" ] }, { @@ -516,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ @@ -526,11 +713,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "10 + 3" ] @@ -544,11 +742,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Sum\n", "a + b" @@ -563,9 +772,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 63, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "7" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# difference\n", "\n", @@ -581,20 +801,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.3333333333333335\n" + ] + } + ], "source": [ "# division\n", "\n", - "division = a / b" + "division = a / b\n", + "print(division)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 65, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(division)" ] @@ -608,9 +848,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 66, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# division: floor division: rounded division\n", "\n", @@ -620,9 +871,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 67, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(floor_division)" ] @@ -636,9 +898,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 68, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Module: Remainder of the division\n", "\n", @@ -654,18 +927,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 69, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "a" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 70, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "b" ] @@ -682,6 +977,26 @@ "execution_count": null, "metadata": {}, "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the number 1 is NOT even\n", + "the number 2 is even\n", + "the number 3 is NOT even\n", + "the number 4 is even\n", + "the number 5 is NOT even\n", + "the number 6 is even\n" + ] + } + ], "source": [ "# Even / odd -> modulo (remainder)\n", "# If the remainder of a division by two is zero: even\n", @@ -691,9 +1006,9 @@ "\n", "for i in list_:\n", " if i % 2 == 0:\n", - " print(f\"El numero {i} es par\")\n", + " print(f\"the number {i} is even\")\n", " else:\n", - " print(f\"El numero {i} NO es par\")" + " print(f\"the number {i} is NOT even\")" ] }, { @@ -719,11 +1034,49 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "the number 1 is NOT even\n", + "the number 2 is even\n", + "the number 3 is NOT even\n", + "the number 4 is even\n", + "the number 5 is NOT even\n", + "the number 6 is even\n", + "the number 7 is NOT even\n", + "the number 8 is even\n", + "the number 9 is NOT even\n", + "the number 10 is even\n" + ] + } + ], "source": [ - "# your solution here" + "# your solution here\n", + "x = 30\n", + "y = 20\n", + "x + y\n", + "x - y\n", + "x * y\n", + "x / y\n", + "print (type(x / y))\n", + "x // y\n", + "print (type(x // y))\n", + "x % y\n", + "\n", + "list_ = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", + "\n", + "for i in list_:\n", + " if i % 2 == 0:\n", + " print(f\"the number {i} is even\")\n", + " else:\n", + " print(f\"the number {i} is NOT even\")\n", + "\n" ] }, { @@ -745,9 +1098,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "This is built-in\n" + ] + } + ], "source": [ "# First, let's explore a built-in method: print\n", "# The print method allows us to print messages to the console.\n", @@ -756,9 +1117,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'THIS IS A STRING'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Another example of a built-in method is upper.\n", "# This method converts a string of text to uppercase.\n", @@ -767,7 +1139,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -778,9 +1150,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "8789" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Next, we use a function from the math library: floor.\n", "# The floor function rounds a number down to the nearest integer.\n", @@ -802,31 +1185,64 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'This is a string'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"This is a string\"" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'This is a string with simple quotes'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "'This is a string with simple quotes'" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'This is a string with simple quotes'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"This is a string with simple quotes\" #End Of Line" ] @@ -840,9 +1256,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'4'" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "this_is_also_a_string = \"4\"\n", "this_is_also_a_string" @@ -857,9 +1284,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(this_is_also_a_string)" ] @@ -890,9 +1328,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'\\nThis is a string\\nwith multiple liness'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"\"\"\n", "This is a string\n", @@ -908,13 +1357,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "This is a string\n", + "with multiple liness\n" + ] + } + ], "source": [ "print(\"\"\"\n", "This is a string\n", - "with multiple liness\"\"\")" + "with multiple liness\"\"\")\n" ] }, { @@ -927,16 +1386,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'😍'" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"😍\" #emojis -> They are strings" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -945,18 +1415,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'😍'" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "heart_face" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(heart_face)" ] @@ -1038,7 +1530,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -1049,9 +1541,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5.7\n" + ] + } + ], "source": [ "print(float_number) # The result will be 5, losing the decimal part." ] @@ -1068,9 +1568,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ "# Example of converting a float to a string\n", "a = 3.14159\n", @@ -1079,9 +1587,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "3.14159\n" + ] + } + ], "source": [ "a = str(a)\n", "print(type(a)) # This will print: \n", @@ -1100,9 +1617,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ "# Example of converting an integer to a string\n", "a = 42\n", @@ -1111,15 +1636,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "42\n" + ] + } + ], "source": [ "a = str(a)\n", "print(type(a)) # This will print: \n", - "print(a) # This will print: \"42\", but now as a string." + "print(a) # This will print: \"42\", but now as a string.\n", + "\n", + " " ] }, { @@ -1140,21 +1676,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "My age is: 41\n" + ] + } + ], "source": [ "# Step 1: Create a variable age with your age as an integer\n", - "age = ...\n", + "age = 41\n", "\n", "# Step 2: Convert the variable age to a string\n", - "age = ...\n", + "age = str(age)\n", "\n", "# Step 3: Concatenate \"My age is: \" with the variable age and store the result in a new variable called message\n", - "message = ...\n", + "message = \"My age is: \" + age\n", "\n", "# Step 4: Print the variable message\n", - "print(...)" + "print(message)" ] }, { @@ -1178,9 +1722,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'hu'" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "salutation = input()\n", "salutation" @@ -1195,7 +1750,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -1211,9 +1766,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'guille'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "name = input(\"Write here your name: \")\n", "name" @@ -1221,9 +1787,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'guille'" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number = input(\"Write here your number: \")\n", "number" @@ -1238,9 +1815,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'guilleguilleguilleguilleguilleguilleguilleguilleguilleguille'" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number * 10" ] @@ -1264,9 +1852,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number = int(input(\"Write here your number: \"))\n", "number" @@ -1274,18 +1873,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(number)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "int(number / 2)" ] @@ -1320,9 +1941,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "greeting = \"Hellooooo\"\n", "type(greeting)" @@ -1330,18 +1962,47 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hellooooo\n" + ] + }, + { + "data": { + "text/plain": [ + "NoneType" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(print(greeting))" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(greeting)" ] @@ -1454,9 +2115,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Hello my name is guille and my age is 41'" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Using the .format() Method to Insert Values into a String\n", "greeting = \"Hello my name is {} and my age is {}\".format(name, age)\n", @@ -1479,11 +2151,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "g\n", + "21\n" + ] + } + ], "source": [ - "# your code here" + "# your code here\n", + "name = input(\"What is your name?\")\n", + "age = input(\"What is your age?\")\n", + "print(name)\n", + "print(age)" ] }, { @@ -1514,7 +2199,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -1530,9 +2215,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'This is a string'" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sample_string.capitalize()" ] @@ -1546,20 +2242,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'THIS IS A STRING'" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sample_string.upper()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# We can also check if the string is in upper case format (uppercase letters)\n", "sample_string.upper().isupper()" @@ -1574,20 +2292,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'this is a string'" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sample_string.lower()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": { "scrolled": false }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sample_string.lower().islower()" ] @@ -1601,9 +2341,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'THIS IS A STRING'" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sample_string.swapcase()" ] @@ -1617,9 +2368,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'This Is A String'" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "sample_string.title()" ] @@ -1701,9 +2463,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "##This is an example.\n" + ] + } + ], "source": [ "# We define a string with some spaces and characters at the beginning\n", "original_string = \" ##This is an example.\"\n", @@ -1775,7 +2545,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -1789,7 +2559,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.1" }, "nbTranslate": { "displayLangs": [