{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<center>\n",
" <img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/IDSNlogo.png\" width=\"300\" alt=\"cognitiveclass.ai logo\" />\n",
"</center>\n",
"\n",
"# String Operations\n",
"\n",
"Estimated time needed: **15** minutes\n",
"\n",
"## Objectives\n",
"\n",
"After completing this lab you will be able to:\n",
"\n",
"- Work with Strings \n",
"- Perform operations on String\n",
"- Manipulate Strings using indexing and escape sequences\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Table of Contents</h2>\n",
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <ul>\n",
" <li>\n",
" <a href=\"#strings\">What are Strings?</a>\n",
" </li>\n",
" <li>\n",
" <a href=\"#index\">Indexing</a>\n",
" <ul>\n",
" <li><a href=\"neg\">Negative Indexing</a></li>\n",
" <li><a href=\"slice\">Slicing</a></li>\n",
" <li><a href=\"stride\">Stride</a></li>\n",
" <li><a href=\"concat\">Concatenate Strings</a></li>\n",
" </ul>\n",
" </li>\n",
" <li>\n",
" <a href=\"#escape\">Escape Sequences</a>\n",
" </li>\n",
" <li>\n",
" <a href=\"#operations\">String Operations</a>\n",
" </li>\n",
" <li>\n",
" <a href=\"#quiz\">Quiz on Strings</a>\n",
" </li>\n",
" </ul>\n",
" \n",
"</div>\n",
"\n",
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"strings\">What are Strings?</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following example shows a string contained within 2 quotation marks:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Use quotation marks for defining string\n",
"\n",
"\"Michael Jackson\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also use single quotation marks:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Use single quotation marks for defining string\n",
"\n",
"'Michael Jackson'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A string can be a combination of spaces and digits: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Digitals and spaces in string\n",
"\n",
"'1 2 3 4 5 6 '"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A string can also be a combination of special characters : \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Special characters in string\n",
"\n",
"'@#2_#]&*^%$'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can print our string using the print statement:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the string\n",
"\n",
"print(\"hello!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can bind or assign a string to another variable:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Assign string to variable\n",
"\n",
"name = \"Michael Jackson\"\n",
"name"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"index\">Indexing</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is helpful to think of a string as an ordered sequence. Each element in the sequence can be accessed using an index represented by the array of numbers: \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%201/images/StringsIndex.png\" width=\"600\" align=\"center\" />\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The first index can be accessed as follows:\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr/>\n",
"<div class=\"alert alert-success alertsuccess\" style=\"margin-top: 20px\">\n",
"[Tip]: Because indexing starts at 0, it means the first index is on the index 0.\n",
"</div>\n",
"<hr/>\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'name' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-d401b00c2a25>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Print the first element in the string\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'name' is not defined"
]
}
],
"source": [
"# Print the first element in the string\n",
"\n",
"print(name[0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can access index 6:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the element on index 6 in the string\n",
"\n",
"print(name[6])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Moreover, we can access the 13th index:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the element on the 13th index in the string\n",
"\n",
"print(name[13])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"neg\">Negative Indexing</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can also use negative indexing with strings:\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%201/images/StringsNeg.png\" width=\"600\" align=\"center\" />\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Negative index can help us to count the element from the end of the string.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The last element is given by the index -1: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the last element in the string\n",
"\n",
"print(name[-1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The first element can be obtained by index -15:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the first element in the string\n",
"\n",
"print(name[-15])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can find the number of characters in a string by using <code>len</code>, short for length:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find the length of string\n",
"\n",
"len(\"Michael Jackson\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"slice\">Slicing</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can obtain multiple characters from a string using slicing, we can obtain the 0 to 4th and 8th to the 12th element: \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%201/images/StringsSlice.png\" width=\"600\" align=\"center\" />\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr/>\n",
"<div class=\"alert alert-success alertsuccess\" style=\"margin-top: 20px\">\n",
"[Tip]: When taking the slice, the first number means the index (start at 0), and the second number means the length from the index to the last element you want (start at 1)\n",
"</div>\n",
"<hr/>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Take the slice on variable name with only index 0 to index 3\n",
"\n",
"name[0:4]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Take the slice on variable name with only index 8 to index 11\n",
"\n",
"name[8:12]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"stride\">Stride</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can also input a stride value as follows, with the '2' indicating that we are selecting every second variable:\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%201/images/StringsStride.png\" width=\"600\" align=\"center\" />\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get every second element. The elments on index 1, 3, 5 ...\n",
"\n",
"name[::2]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also incorporate slicing with the stride. In this case, we select the first five elements and then use the stride: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get every second element in the range from index 0 to index 4\n",
"\n",
"name[0:5:2]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"concat\">Concatenate Strings</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can concatenate or combine strings by using the addition symbols, and the result is a new string that is a combination of both:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Concatenate two strings\n",
"\n",
"statement = name + \"is the best\"\n",
"statement"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To replicate values of a string we simply multiply the string by the number of times we would like to replicate it. In this case, the number is three. The result is a new string, and this new string consists of three copies of the original string:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the string for 3 times\n",
"\n",
"3 * \"Michael Jackson\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can create a new string by setting it to the original variable. Concatenated with a new string, the result is a new string that changes from Michael Jackson to “Michael Jackson is the best\".\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Concatenate strings\n",
"\n",
"name = \"Michael Jackson\"\n",
"name = name + \" is the best\"\n",
"name"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"escape\">Escape Sequences</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Back slashes represent the beginning of escape sequences. Escape sequences represent strings that may be difficult to input. For example, back slash \"n\" represents a new line. The output is given by a new line after the back slash \"n\" is encountered:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# New line escape sequence\n",
"\n",
"print(\" Michael Jackson \\n is the best\" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Similarly, back slash \"t\" represents a tab: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Tab escape sequence\n",
"\n",
"print(\" Michael Jackson \\t is the best\" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" If you want to place a back slash in your string, use a double back slash:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Include back slash in string\n",
"\n",
"print(\" Michael Jackson \\\\ is the best\" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can also place an \"r\" before the string to display the backslash:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# r will tell python that string will be display as raw string\n",
"\n",
"print(r\" Michael Jackson \\ is the best\" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"operations\">String Operations</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are many string operation methods in Python that can be used to manipulate the data. We are going to use some basic string operations on the data. \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's try with the method <code>upper</code>; this method converts lower case characters to upper case characters:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Convert all the characters in string to upper case\n",
"\n",
"a = \"Thriller is the sixth studio album\"\n",
"print(\"before upper:\", a)\n",
"b = a.upper()\n",
"print(\"After upper:\", b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The method <code>replace</code> replaces a segment of the string, i.e. a substring with a new string. We input the part of the string we would like to change. The second argument is what we would like to exchange the segment with, and the result is a new string with the segment changed: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Replace the old substring with the new target substring is the segment has been found in the string\n",
"\n",
"a = \"Michael Jackson is the best\"\n",
"b = a.replace('Michael', 'Janet')\n",
"b"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The method <code>find</code> finds a sub-string. The argument is the substring you would like to find, and the output is the first index of the sequence. We can find the sub-string <code>jack</code> or <code>el<code>. \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%201/images/StringsFind.png\" width=\"600\" align=\"center\" />\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find the substring in the string. Only the index of the first elment of substring in string will be the output\n",
"\n",
"name = \"Michael Jackson\"\n",
"name.find('el')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find the substring in the string.\n",
"\n",
"name.find('Jack')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If the sub-string is not in the string then the output is a negative one. For example, the string 'Jasdfasdasdf' is not a substring:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# If cannot find the substring in the string\n",
"\n",
"name.find('Jasdfasdasdf')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"quiz\">Quiz on Strings</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the value of the variable <code>a</code> after the following code is executed? \n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute \n",
"\n",
"a = \"1\"\n",
"print(a)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"\"1\"\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the value of the variable <code>b</code> after the following code is executed?\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"b = \"2\"\n",
"print(b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"\"2\"\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the value of the variable <code>c</code> after the following code is executed?\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute \n",
"\n",
"c = a + b\n",
"print(c)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"\"12\"\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the variable <code>d</code> use slicing to print out the first three elements:\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ABC\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"d = \"ABCDEFG\"\n",
"print(d[0:3])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"print(d[:3]) \n",
"\n",
"# or \n",
"\n",
"print(d[0:3])\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use a stride value of 2 to print out every second character of the string <code>e</code>: \n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"correct\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"e = 'clocrkr1e1c1t'\n",
"print(e[::2])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"print(e[::2])\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print out a backslash:\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\\ \n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"print(r\"\\ \")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"print(\"\\\\\\\\\")\n",
"\n",
"or\n",
"\n",
"print(r\"\\ \")\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert the variable <code>f</code> to uppercase:\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"YOU ARE WRONG\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"f = \"You are wrong\"\n",
"print(f.upper())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"f.upper()\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the variable <code>g</code>, and find the first index of the sub-string <code>snow</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"g = \"Mary had a little lamb Little lamb, little lamb Mary had a little lamb \\\n",
"Its fleece was white as snow And everywhere that Mary went Mary went, Mary went \\\n",
"Everywhere that Mary went The lamb was sure to go\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"g.find(\"snow\")\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the variable <code>g</code>, replace the sub-string <code>Mary</code> with <code>Bob</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Write your code below and press Shift+Enter to execute\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here for the solution</summary>\n",
"\n",
"```python\n",
"g.replace(\"Mary\", \"Bob\")\n",
"\n",
"```\n",
"\n",
"</details>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n",
"<h2>The last exercise!</h2>\n",
"<p>Congratulations, you have completed your first lesson and hands-on lab in Python. However, there is one more thing you need to do. The Data Science community encourages sharing work. The best way to share and showcase your work is to share it on GitHub. By sharing your notebook on GitHub you are not only building your reputation with fellow data scientists, but you can also show it off when applying for a job. Even though this was your first piece of work, it is never too early to start building good habits. So, please read and follow <a href=\"https://cognitiveclass.ai/blog/data-scientists-stand-out-by-sharing-your-notebooks/\" target=\"_blank\">this article</a> to learn how to share your work.\n",
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Author\n",
"\n",
"<a href=\"https://www.linkedin.com/in/joseph-s-50398b136/\" target=\"_blank\">Joseph Santarcangelo</a>\n",
"\n",
"## Change Log\n",
"\n",
"| Date (YYYY-MM-DD) | Version | Changed By | Change Description |\n",
"| ----------------- | ------- | ---------- | ----------------------------------- |\n",
"| 2020-11-11 | 2.1 | Aije | Updated variable names to lowercase |\n",
"| 2020-08-26 | 2.0 | Lavanya | Moved lab to course repo in GitLab |\n",
"\n",
"## <h3 align=\"center\"> © IBM Corporation 2020. All rights reserved. <h3/>\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.13"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Created on Skills Network Labs
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.