From dffed9809ce51e3b8335ab549d892393cf12730f Mon Sep 17 00:00:00 2001 From: Jeffrey Katz Date: Thu, 8 Mar 2018 16:18:03 -0500 Subject: [PATCH 01/12] formatting --- .gitignore | 1 + Practice with DataTypes.ipynb | 382 ------------------ README.md | 159 ++++++++ ... DataTypes-checkpoint.ipynb => index.ipynb | 0 4 files changed, 160 insertions(+), 382 deletions(-) create mode 100644 .gitignore delete mode 100644 Practice with DataTypes.ipynb create mode 100644 README.md rename .ipynb_checkpoints/Practice with DataTypes-checkpoint.ipynb => index.ipynb (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..763513e910 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ipynb_checkpoints diff --git a/Practice with DataTypes.ipynb b/Practice with DataTypes.ipynb deleted file mode 100644 index f70736eebf..0000000000 --- a/Practice with DataTypes.ipynb +++ /dev/null @@ -1,382 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Practice with datatypes" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Introduction" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the past few lessons, we have learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now let's put that knowledge into action.\n", - "\n", - "In this lesson we'll imagine that you just stopped by an Python programming conference and met a few people there. You exchanged some information with a very industrious person who you met, and want to use your programming skills to format this information correctly. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Here to mingle " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The next morning you take out the business card, ready to format it using your programming skills, and here is what you find." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![](./biz-card-mistakes.jpg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Yea, he may not be the best person to get to know. But we know that when people fill out forms, they misenter information all of the time. As a celebrity once said, \"I'm really getting into the Internet lately, I just wish it were more organized.\"\n", - "\n", - "And as data scientists, we also see the need of organizing and cleaning data to then make sense of it. So let's get to work." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Solving your first lab" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is your first lab, and here you'll see that we have provided some data for you. Next to the data, you will see a comment indicating what the data should look after you change it. Let's do the first one together. For example, let's say we want to capitalize all of the letters of \"art vandlay\" (to remind ourselves of how he made his introduction). You'll see the following:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'art vandelay'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\" # 'ART VANDELAY'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That hash tag to the right is a comment. Comments are used for programmers to annotate their code. But a comment has no impact on the code." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'hello'" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'hello'\n", - "### whattttt" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you press shift+enter to run the code in the cell, you will see that Python happily ignores the comment. So in labs, we provide the comment to indicate what you should see as the return value of your code. When you press shift+enter, and the output below matches the comment to the right of your code, you did it correctly." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> In future labs, Learn will check your code to ensure that you did it correctly. But for your first lab, this works fine." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And change it to the following:" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'ART VANDELAY'" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\".upper() # 'ART VANDELAY'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Get going with strings" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "First use the `title` method to capitalize the first letter of each word in \"art vandelay\"`." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Art Vandelay'" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\".title() # 'Art Vandelay'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now let's capitalize all of the letters of \"Ceo\"." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'CEO'" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"Ceo\".upper() # 'CEO'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now write a method that get answer a question about our email addresses. Every email address should end with \".com\". Use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. " - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art.vandelay@vandelay.cop\".endswith(\".com\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see, the website \"vandelay.com\" is not preceded by `\"www.\"`. Use the plus sign to change the website 'vandelay.com' to the string `'www.vandelay.com'`." - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'www.vandelay.com'" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'www.' + 'vandelay.com' # 'www.vandelay.com'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Working with numbers" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finally, Mr. Vandelay gave us his phone number, but he actually has a second number different ones listed. All three numbers are the same except for the ending. Coerce the string of his phone number to an `int` and add one, then add two to change the number. " - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "7285553335" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "int(\"7285553334\") + 1 # 7285553335" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "7285553336" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "int(\"7285553334\") + 2 # 7285553336" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Summary" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Your first lab done! Sweet. In this lab, you practiced working with string methods to operate on and answer questions about strings. You wrote methods that return Booleans. And you changed strings to an `int` to then perform addition. So much of working with data, is ensuring that our data is properly formatted so we can then operate on it and in this lab you saw how to use code to just that." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "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.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/README.md b/README.md new file mode 100644 index 0000000000..527663f8d1 --- /dev/null +++ b/README.md @@ -0,0 +1,159 @@ + +# Practice with datatypes + +### Introduction + +In the past few lessons, we have learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now let's put that knowledge into action. + +In this lesson we'll imagine that you just stopped by an Python programming conference and met a few people there. You exchanged some information with a very industrious person who you met, and want to use your programming skills to format this information correctly. + +### Learning Objectives + +### Here to mingle + +The next morning you take out the business card, ready to format it using your programming skills, and here is what you find. + +![](./biz-card-mistakes.jpg) + +Yea, he may not be the best person to get to know. But we know that when people fill out forms, they misenter information all of the time. As a celebrity once said, "I'm really getting into the Internet lately, I just wish it were more organized." + +And as data scientists, we also see the need of organizing and cleaning data to then make sense of it. So let's get to work. + +### Solving your first lab + +This is your first lab, and here you'll see that we have provided some data for you. Next to the data, you will see a comment indicating what the data should look after you change it. Let's do the first one together. For example, let's say we want to capitalize all of the letters of "art vandlay" (to remind ourselves of how he made his introduction). You'll see the following: + + +```python +"art vandelay" # 'ART VANDELAY' +``` + + + + + 'art vandelay' + + + +That hash tag to the right is a comment. Comments are used for programmers to annotate their code. But a comment has no impact on the code. + + +```python +'hello' +### whattttt +``` + + + + + 'hello' + + + +If you press shift+enter to run the code in the cell, you will see that Python happily ignores the comment. So in labs, we provide the comment to indicate what you should see as the return value of your code. When you press shift+enter, and the output below matches the comment to the right of your code, you did it correctly. + +> In future labs, Learn will check your code to ensure that you did it correctly. But for your first lab, this works fine. + +And change it to the following: + + +```python +"art vandelay".upper() # 'ART VANDELAY' +``` + + + + + 'ART VANDELAY' + + + +### Get going with strings + +First use the `title` method to capitalize the first letter of each word in "art vandelay"`. + + +```python +"art vandelay" # 'Art Vandelay' +``` + + + + + 'Art Vandelay' + + + +Now let's uppercase all of the letters of "Ceo". + + +```python +"Ceo" # 'CEO' +``` + + + + + 'CEO' + + + +Now write a method that get answer a question about our email addresses. Every email address should end with ".com". Use your knowledge of string methods to check if the email address ends with ".com" and return `True` or `False` accordingly. + + +```python +"art.vandelay@vandelay.cop" # False +``` + + + + + 'art.vandelay@vandelay.cop' + + + +As you can see, the website "vandelay.com" is not preceded by `"www."`. Use the plus sign to change the website 'vandelay.com' to the string `'www.vandelay.com'`. + + +```python +'vandelay.com' # 'www.vandelay.com' +``` + + + + + 'vandelay.com' + + + +### Working with numbers + +Finally, Mr. Vandelay gave us his phone number, but he actually has a second number different ones listed. All three numbers are the same except for the ending. Coerce the string of his phone number to an `int` and add one, then add two to change the number. + + +```python +"7285553334" # 7285553335 +``` + + + + + '7285553334' + + + + +```python +"7285553334" # 7285553336 +``` + + + + + '7285553334' + + + +### Summary + +Your first lab done! Sweet. In this lab, you practiced working with string methods to operate on and answer questions about strings. You wrote methods that return Booleans. And you changed strings to an `int` to then perform addition. So much of working with data, is ensuring that our data is properly formatted so we can then operate on it and in this lab you saw how to use code to just that. diff --git a/.ipynb_checkpoints/Practice with DataTypes-checkpoint.ipynb b/index.ipynb similarity index 100% rename from .ipynb_checkpoints/Practice with DataTypes-checkpoint.ipynb rename to index.ipynb From 23d9d5035efd496c934a583e6c78e9c2a6cf328f Mon Sep 17 00:00:00 2001 From: Jeffrey Katz Date: Thu, 8 Mar 2018 16:23:13 -0500 Subject: [PATCH 02/12] change readme --- README.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 527663f8d1..2d42dbc3d5 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ First use the `title` method to capitalize the first letter of each word in "art ```python -"art vandelay" # 'Art Vandelay' +"art vandelay".title() # 'Art Vandelay' ``` @@ -84,11 +84,11 @@ First use the `title` method to capitalize the first letter of each word in "art -Now let's uppercase all of the letters of "Ceo". +Now let's capitalize all of the letters of "Ceo". ```python -"Ceo" # 'CEO' +"Ceo".upper() # 'CEO' ``` @@ -102,13 +102,13 @@ Now write a method that get answer a question about our email addresses. Every ```python -"art.vandelay@vandelay.cop" # False +"art.vandelay@vandelay.cop".endswith(".com") ``` - 'art.vandelay@vandelay.cop' + False @@ -116,13 +116,13 @@ As you can see, the website "vandelay.com" is not preceded by `"www."`. Use the ```python -'vandelay.com' # 'www.vandelay.com' +'www.' + 'vandelay.com' # 'www.vandelay.com' ``` - 'vandelay.com' + 'www.vandelay.com' @@ -132,28 +132,33 @@ Finally, Mr. Vandelay gave us his phone number, but he actually has a second num ```python -"7285553334" # 7285553335 +int("7285553334") + 1 # 7285553335 ``` - '7285553334' + 7285553335 ```python -"7285553334" # 7285553336 +int("7285553334") + 2 # 7285553336 ``` - '7285553334' + 7285553336 ### Summary Your first lab done! Sweet. In this lab, you practiced working with string methods to operate on and answer questions about strings. You wrote methods that return Booleans. And you changed strings to an `int` to then perform addition. So much of working with data, is ensuring that our data is properly formatted so we can then operate on it and in this lab you saw how to use code to just that. + + +```python + +``` From b657432f0370672f1121c325074dd3ad500f3dfe Mon Sep 17 00:00:00 2001 From: Jeffrey Katz Date: Thu, 8 Mar 2018 21:41:32 -0500 Subject: [PATCH 03/12] add learn file --- .learn | 1 + 1 file changed, 1 insertion(+) create mode 100644 .learn diff --git a/.learn b/.learn new file mode 100644 index 0000000000..a7cf753467 --- /dev/null +++ b/.learn @@ -0,0 +1 @@ +jupyter_notebook: true From 34b3c7c3d5210742160593a60a3cb411342d91fd Mon Sep 17 00:00:00 2001 From: tkoar Date: Tue, 3 Apr 2018 12:19:43 -0400 Subject: [PATCH 04/12] updating solution --- README.md | 45 ++++++++++++---------- index.ipynb | 107 ++++++++++++++++++++++++++-------------------------- 2 files changed, 79 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 7ea7a9305f..65f55b5fcd 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,31 @@ In the past few lessons, we have learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now let's put that knowledge into action. -In this lesson we'll imagine that you just stopped by an Python programming conference and met a few people there. You exchanged some information with a very industrious person who you met, and want to use your programming skills to format this information correctly. +In this lesson we'll imagine that we were at a nice social gathering and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. We want to use our programming skills to format this information correctly. ### Learning Objectives +* Manipulate strings with built-in methods +* Practice coercing data types and changing numbers ### Here to mingle -The next morning you take out the business card, ready to format it using your programming skills, and here is what you find. +The next morning we take out the business card, ready to format it using our programming skills, and here is what we find. -![](./biz-card-mistakes.jpg) +![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg) -Yea, he may not be the best person to get to know. But we know that when people fill out forms, they misenter information all of the time. As a celebrity once said, "I'm really getting into the Internet lately, I just wish it were more organized." +Yea, Mr. Vandelay may not be the best person to get to know or the best at designing business cards, but like Mr. Vandelay, we know that people misenter information on forms all the time. -And as data scientists, we also see the need of organizing and cleaning data to then make sense of it. So let's get to work. +So as data scientists, we often need to clean and organize data before we can make sense of it. Let's get to work. -### Solving your first lab +### Solving our first lab -This is your first lab, and here you'll see that we have provided some data for you. Next to the data, you will see a comment indicating what the data should look after you change it. Let's do the first one together. For example, let's say we want to capitalize all of the letters of "art vandlay" (to remind ourselves of how he made his introduction). You'll see the following: +This is our first lab, and here we'll see that there is some data already provided for us. Next to the data, we will see a comment indicating what the data should look like after we change it. + +For example, let's say we want to capitalize all of the letters of "art vandlay". We'll see the following: ```python -"art vandelay" # 'ART VANDELAY' +"art vandelay" # "ART VANDELAY" ``` @@ -35,12 +39,13 @@ This is your first lab, and here you'll see that we have provided some data for -That hash tag to the right is a comment. Comments are used for programmers to annotate their code. But a comment has no impact on the code. +Notice that there is no output below the gray code above. This is because Jupyter notebooks do not automatically run our code - so they do not automatically know the output. To display the output, we must **run** the code by clicking on the gray cell and then pressing shift + enter. Let's try it in the cell above and see our output appear below. + +Ok, once we see the output take a look at the cell below with the hash tag to the right of the string, `'hello'`. This is a comment like the above. Comments are used for programmers to annotate their code, but a comment has no impact on the code. We can see this by running the cell below (again, press shift + enter). ```python -'hello' -### whattttt +'hello' ### whattttt ``` @@ -50,11 +55,11 @@ That hash tag to the right is a comment. Comments are used for programmers to a -If you press shift+enter to run the code in the cell, you will see that Python happily ignores the comment. So in labs, we provide the comment to indicate what you should see as the return value of your code. When you press shift+enter, and the output below matches the comment to the right of your code, you did it correctly. +After pressing shift+enter on the cell above, we see that still Python happily ignores our comment. So here (and in future labs), a comment will be provided to indicate what we should see as the return value of our code. When we press shift+enter, and the output below matches the comment to the right of our code, we did it correctly. -> In future labs, Learn will check your code to ensure that you did it correctly. But for your first lab, this works fine. +> In future labs, Learn will check our code to ensure that we did it correctly. But for our first lab, this works fine. -And change it to the following: +To get our output to match the comment we will change it to the following: ```python @@ -84,7 +89,7 @@ First use the `title` method to capitalize the first letter of each word in "art -Now let's capitalize all of the letters of "Ceo". +Now let's uppercase all of the letters of "Ceo". ```python @@ -98,11 +103,11 @@ Now let's capitalize all of the letters of "Ceo". -Now write a method that get answer a question about our email addresses. Every email address should end with ".com". Use your knowledge of string methods to check if the email address ends with ".com" and return `True` or `False` accordingly. +Next, write a method that answers a question about our email addresses. Every email address should end with ".com". We can use our knowledge of string methods to check if the email address ends with ".com" and return `True` or `False` accordingly. ```python -"art.vandelay@vandelay.cop".endswith(".com") +"art.vandelay@vandelay.co".endswith('.com') # False ``` @@ -112,7 +117,7 @@ Now write a method that get answer a question about our email addresses. Every -As you can see, the website "vandelay.com" is not preceded by `"www."`. Use the plus sign to change the website 'vandelay.com' to the string `'www.vandelay.com'`. +As you can see below, the website "vandelay.com" is not preceded by `"www."`. We can perform what is called string interpolation to fix this! Use the plus sign, `'+'`, to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`. ```python @@ -128,7 +133,7 @@ As you can see, the website "vandelay.com" is not preceded by `"www."`. Use the ### Working with numbers -Finally, Mr. Vandelay gave us his phone number, but he actually has a second number different ones listed. All three numbers are the same except for the ending. Coerce the string of his phone number to an `int` and add one, then add two to change the number. +Finally, Mr. Vandelay gave us his phone number, but he actually has two other phone numbers that are different from the one listed. All three numbers are basically the same with the excepion of the ending. Below, start by coercing the first phone number, which is currently a string, to an `int` and add one. Next do the same to the second phone number but increase it by two. ```python @@ -156,4 +161,4 @@ int("7285553334") + 2 # 7285553336 ### Summary -Your first lab done! Sweet. In this lab, you practiced working with string methods to operate on and answer questions about strings. You wrote methods that return Booleans. And you changed strings to an `int` to then perform addition. So much of working with data, is ensuring that our data is properly formatted so we can then operate on it and in this lab you saw how to use code to just that. +Our first lab is done! Sweet. In this lab, we practiced working with string methods to operate on and answer questions about strings. We wrote methods that return Booleans and changed strings to intergers in order to perform addition. So much of working with data is ensuring that it is properly formatted so we can then operate on it, and in this lab, we saw how to use code to do just that. diff --git a/index.ipynb b/index.ipynb index f70736eebf..0b10fb9c18 100644 --- a/index.ipynb +++ b/index.ipynb @@ -20,14 +20,16 @@ "source": [ "In the past few lessons, we have learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now let's put that knowledge into action.\n", "\n", - "In this lesson we'll imagine that you just stopped by an Python programming conference and met a few people there. You exchanged some information with a very industrious person who you met, and want to use your programming skills to format this information correctly. " + "In this lesson we'll imagine that we were at a nice social gathering and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. We want to use our programming skills to format this information correctly. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Learning Objectives" + "### Learning Objectives\n", + "* Manipulate strings with built-in methods\n", + "* Practice coercing data types and changing numbers" ] }, { @@ -41,42 +43,44 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The next morning you take out the business card, ready to format it using your programming skills, and here is what you find." + "The next morning we take out the business card, ready to format it using our programming skills, and here is what we find." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "![](./biz-card-mistakes.jpg)" + "![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Yea, he may not be the best person to get to know. But we know that when people fill out forms, they misenter information all of the time. As a celebrity once said, \"I'm really getting into the Internet lately, I just wish it were more organized.\"\n", + "Yea, Mr. Vandelay may not be the best person to get to know or the best at designing business cards, but like Mr. Vandelay, we know that people misenter information on forms all the time.\n", "\n", - "And as data scientists, we also see the need of organizing and cleaning data to then make sense of it. So let's get to work." + "So as data scientists, we often need to clean and organize data before we can make sense of it. Let's get to work. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Solving your first lab" + "### Solving our first lab" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "This is your first lab, and here you'll see that we have provided some data for you. Next to the data, you will see a comment indicating what the data should look after you change it. Let's do the first one together. For example, let's say we want to capitalize all of the letters of \"art vandlay\" (to remind ourselves of how he made his introduction). You'll see the following:" + "This is our first lab, and here we'll see that there is some data already provided for us. Next to the data, we will see a comment indicating what the data should look like after we change it. \n", + "\n", + "For example, let's say we want to capitalize all of the letters of \"art vandlay\". We'll see the following:" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -85,25 +89,32 @@ "'art vandelay'" ] }, - "execution_count": 3, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "\"art vandelay\" # 'ART VANDELAY'" + "\"art vandelay\" # \"ART VANDELAY\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Notice that there is no output below the gray code above. This is because Jupyter notebooks do not automatically run our code - so they do not automatically know the output. To display the output, we must **run** the code by clicking on the gray cell and then pressing shift + enter. Let's try it in the cell above and see our output appear below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "That hash tag to the right is a comment. Comments are used for programmers to annotate their code. But a comment has no impact on the code." + "Ok, once we see the output take a look at the cell below with the hash tag to the right of the string, `'hello'`. This is a comment like the above. Comments are used for programmers to annotate their code, but a comment has no impact on the code. We can see this by running the cell below (again, press shift + enter)." ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -112,40 +123,39 @@ "'hello'" ] }, - "execution_count": 8, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "'hello'\n", - "### whattttt" + "'hello' ### whattttt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "If you press shift+enter to run the code in the cell, you will see that Python happily ignores the comment. So in labs, we provide the comment to indicate what you should see as the return value of your code. When you press shift+enter, and the output below matches the comment to the right of your code, you did it correctly." + "After pressing shift+enter on the cell above, we see that still Python happily ignores our comment. So here (and in future labs), a comment will be provided to indicate what we should see as the return value of our code. When we press shift+enter, and the output below matches the comment to the right of our code, we did it correctly." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "> In future labs, Learn will check your code to ensure that you did it correctly. But for your first lab, this works fine." + "> In future labs, Learn will check our code to ensure that we did it correctly. But for our first lab, this works fine." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "And change it to the following:" + "To get our output to match the comment we will change it to the following:" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -154,7 +164,7 @@ "'ART VANDELAY'" ] }, - "execution_count": 12, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -179,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -188,7 +198,7 @@ "'Art Vandelay'" ] }, - "execution_count": 15, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -201,12 +211,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now let's capitalize all of the letters of \"Ceo\"." + "Now let's uppercase all of the letters of \"Ceo\"." ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -215,7 +225,7 @@ "'CEO'" ] }, - "execution_count": 19, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -228,12 +238,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now write a method that get answer a question about our email addresses. Every email address should end with \".com\". Use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. " + "Next, write a method that answers a question about our email addresses. Every email address should end with \".com\". We can use our knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. " ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -242,25 +252,25 @@ "False" ] }, - "execution_count": 21, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "\"art.vandelay@vandelay.cop\".endswith(\".com\")" + "\"art.vandelay@vandelay.co\".endswith('.com') # False" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "As you can see, the website \"vandelay.com\" is not preceded by `\"www.\"`. Use the plus sign to change the website 'vandelay.com' to the string `'www.vandelay.com'`." + "As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. We can perform what is called string interpolation to fix this! Use the plus sign, `'+'`, to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`." ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 7, "metadata": { "scrolled": true }, @@ -271,7 +281,7 @@ "'www.vandelay.com'" ] }, - "execution_count": 23, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -291,12 +301,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Finally, Mr. Vandelay gave us his phone number, but he actually has a second number different ones listed. All three numbers are the same except for the ending. Coerce the string of his phone number to an `int` and add one, then add two to change the number. " + "Finally, Mr. Vandelay gave us his phone number, but he actually has two other phone numbers that are different from the one listed. All three numbers are basically the same with the excepion of the ending. Below, start by coercing the first phone number, which is currently a string, to an `int` and add one. Next do the same to the second phone number but increase it by two." ] }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -305,7 +315,7 @@ "7285553335" ] }, - "execution_count": 28, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -316,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -325,7 +335,7 @@ "7285553336" ] }, - "execution_count": 30, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -345,36 +355,27 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Your first lab done! Sweet. In this lab, you practiced working with string methods to operate on and answer questions about strings. You wrote methods that return Booleans. And you changed strings to an `int` to then perform addition. So much of working with data, is ensuring that our data is properly formatted so we can then operate on it and in this lab you saw how to use code to just that." + "Our first lab is done! Sweet. In this lab, we practiced working with string methods to operate on and answer questions about strings. We wrote methods that return Booleans and changed strings to intergers in order to perform addition. So much of working with data is ensuring that it is properly formatted so we can then operate on it, and in this lab, we saw how to use code to do just that." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.1" + "pygments_lexer": "ipython2", + "version": "2.7.14" } }, "nbformat": 4, From d84317ad2541c237f160b19396655b6c1d3b454e Mon Sep 17 00:00:00 2001 From: "matthew.mitchell" Date: Thu, 23 May 2019 15:32:25 -0400 Subject: [PATCH 05/12] Removing markdown cells in prep for markdown merger. --- README.md | 16 ---------------- index.ipynb | 44 +++++--------------------------------------- 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 65f55b5fcd..2307a357b9 100644 --- a/README.md +++ b/README.md @@ -57,22 +57,6 @@ Ok, once we see the output take a look at the cell below with the hash tag to th After pressing shift+enter on the cell above, we see that still Python happily ignores our comment. So here (and in future labs), a comment will be provided to indicate what we should see as the return value of our code. When we press shift+enter, and the output below matches the comment to the right of our code, we did it correctly. -> In future labs, Learn will check our code to ensure that we did it correctly. But for our first lab, this works fine. - -To get our output to match the comment we will change it to the following: - - -```python -"art vandelay".upper() # 'ART VANDELAY' -``` - - - - - 'ART VANDELAY' - - - ### Get going with strings First use the `title` method to capitalize the first letter of each word in "art vandelay"`. diff --git a/index.ipynb b/index.ipynb index 0b10fb9c18..0c7cbf4087 100644 --- a/index.ipynb +++ b/index.ipynb @@ -139,40 +139,6 @@ "After pressing shift+enter on the cell above, we see that still Python happily ignores our comment. So here (and in future labs), a comment will be provided to indicate what we should see as the return value of our code. When we press shift+enter, and the output below matches the comment to the right of our code, we did it correctly." ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> In future labs, Learn will check our code to ensure that we did it correctly. But for our first lab, this works fine." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To get our output to match the comment we will change it to the following:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'ART VANDELAY'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\".upper() # 'ART VANDELAY'" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -361,21 +327,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.14" + "pygments_lexer": "ipython3", + "version": "3.6.5" } }, "nbformat": 4, From c53651eaeb8cc1a00bb3ac158cd9a3c1c346545e Mon Sep 17 00:00:00 2001 From: "matthew.mitchell" Date: Thu, 23 May 2019 15:33:31 -0400 Subject: [PATCH 06/12] removing md cell --- index.ipynb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/index.ipynb b/index.ipynb index 0c7cbf4087..dc24758d9b 100644 --- a/index.ipynb +++ b/index.ipynb @@ -53,15 +53,6 @@ "![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Yea, Mr. Vandelay may not be the best person to get to know or the best at designing business cards, but like Mr. Vandelay, we know that people misenter information on forms all the time.\n", - "\n", - "So as data scientists, we often need to clean and organize data before we can make sense of it. Let's get to work. " - ] - }, { "cell_type": "markdown", "metadata": {}, From 292456f02e10cc52111093b42198d452c325f859 Mon Sep 17 00:00:00 2001 From: "matthew.mitchell" Date: Thu, 23 May 2019 15:33:48 -0400 Subject: [PATCH 07/12] Updating directions. --- README.md | 40 +++--- index.ipynb | 341 +--------------------------------------------------- 2 files changed, 20 insertions(+), 361 deletions(-) diff --git a/README.md b/README.md index 2307a357b9..5e3657b68d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Practice with datatypes +# Practice with Data Types ### Introduction -In the past few lessons, we have learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now let's put that knowledge into action. +In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action. -In this lesson we'll imagine that we were at a nice social gathering and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. We want to use our programming skills to format this information correctly. +Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. ### Learning Objectives * Manipulate strings with built-in methods @@ -13,19 +13,15 @@ In this lesson we'll imagine that we were at a nice social gathering and exchang ### Here to mingle -The next morning we take out the business card, ready to format it using our programming skills, and here is what we find. +The next morning you take out the business card, ready to format it using your programming skills, and here is what we find. ![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg) -Yea, Mr. Vandelay may not be the best person to get to know or the best at designing business cards, but like Mr. Vandelay, we know that people misenter information on forms all the time. +### String Transformations -So as data scientists, we often need to clean and organize data before we can make sense of it. Let's get to work. +When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. -### Solving our first lab - -This is our first lab, and here we'll see that there is some data already provided for us. Next to the data, we will see a comment indicating what the data should look like after we change it. - -For example, let's say we want to capitalize all of the letters of "art vandlay". We'll see the following: +Here's a simple example of how you might go about doing this: ```python @@ -39,9 +35,9 @@ For example, let's say we want to capitalize all of the letters of "art vandlay" -Notice that there is no output below the gray code above. This is because Jupyter notebooks do not automatically run our code - so they do not automatically know the output. To display the output, we must **run** the code by clicking on the gray cell and then pressing shift + enter. Let's try it in the cell above and see our output appear below. +If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. -Ok, once we see the output take a look at the cell below with the hash tag to the right of the string, `'hello'`. This is a comment like the above. Comments are used for programmers to annotate their code, but a comment has no impact on the code. We can see this by running the cell below (again, press shift + enter). +Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. ```python @@ -55,11 +51,13 @@ Ok, once we see the output take a look at the cell below with the hash tag to th -After pressing shift+enter on the cell above, we see that still Python happily ignores our comment. So here (and in future labs), a comment will be provided to indicate what we should see as the return value of our code. When we press shift+enter, and the output below matches the comment to the right of our code, we did it correctly. +After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code. ### Get going with strings -First use the `title` method to capitalize the first letter of each word in "art vandelay"`. +With that, use the appropriate string method to transform each string to match the desired output in the comment. + +Use the `title` method to capitalize the first letter of each word in "art vandelay"`. ```python @@ -73,7 +71,7 @@ First use the `title` method to capitalize the first letter of each word in "art -Now let's uppercase all of the letters of "Ceo". +Now use the `uppercase` method to capitalize all of the letters of "Ceo". ```python @@ -87,7 +85,7 @@ Now let's uppercase all of the letters of "Ceo". -Next, write a method that answers a question about our email addresses. Every email address should end with ".com". We can use our knowledge of string methods to check if the email address ends with ".com" and return `True` or `False` accordingly. +Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with ".com". With that, use your knowledge of string methods to check if the email address ends with ".com" and return `True` or `False` accordingly. ```python @@ -101,7 +99,7 @@ Next, write a method that answers a question about our email addresses. Every e -As you can see below, the website "vandelay.com" is not preceded by `"www."`. We can perform what is called string interpolation to fix this! Use the plus sign, `'+'`, to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`. +As you can see below, the website "vandelay.com" is not preceded by `"www."`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```"This is the start" + "and this is the end"``` would return ```"This is the start and this is the end"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`. ```python @@ -115,9 +113,9 @@ As you can see below, the website "vandelay.com" is not preceded by `"www."`. We -### Working with numbers +### String Slicing -Finally, Mr. Vandelay gave us his phone number, but he actually has two other phone numbers that are different from the one listed. All three numbers are basically the same with the excepion of the ending. Below, start by coercing the first phone number, which is currently a string, to an `int` and add one. Next do the same to the second phone number but increase it by two. +Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```"George"[:4]``` which would return ```"Geor"```. ```python @@ -145,4 +143,4 @@ int("7285553334") + 2 # 7285553336 ### Summary -Our first lab is done! Sweet. In this lab, we practiced working with string methods to operate on and answer questions about strings. We wrote methods that return Booleans and changed strings to intergers in order to perform addition. So much of working with data is ensuring that it is properly formatted so we can then operate on it, and in this lab, we saw how to use code to do just that. +Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills. diff --git a/index.ipynb b/index.ipynb index dc24758d9b..3707a09e87 100644 --- a/index.ipynb +++ b/index.ipynb @@ -1,340 +1 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Practice with datatypes" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Introduction" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the past few lessons, we have learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now let's put that knowledge into action.\n", - "\n", - "In this lesson we'll imagine that we were at a nice social gathering and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. We want to use our programming skills to format this information correctly. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives\n", - "* Manipulate strings with built-in methods\n", - "* Practice coercing data types and changing numbers" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Here to mingle " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The next morning we take out the business card, ready to format it using our programming skills, and here is what we find." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Solving our first lab" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is our first lab, and here we'll see that there is some data already provided for us. Next to the data, we will see a comment indicating what the data should look like after we change it. \n", - "\n", - "For example, let's say we want to capitalize all of the letters of \"art vandlay\". We'll see the following:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'art vandelay'" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\" # \"ART VANDELAY\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Notice that there is no output below the gray code above. This is because Jupyter notebooks do not automatically run our code - so they do not automatically know the output. To display the output, we must **run** the code by clicking on the gray cell and then pressing shift + enter. Let's try it in the cell above and see our output appear below." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ok, once we see the output take a look at the cell below with the hash tag to the right of the string, `'hello'`. This is a comment like the above. Comments are used for programmers to annotate their code, but a comment has no impact on the code. We can see this by running the cell below (again, press shift + enter)." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'hello'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'hello' ### whattttt" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After pressing shift+enter on the cell above, we see that still Python happily ignores our comment. So here (and in future labs), a comment will be provided to indicate what we should see as the return value of our code. When we press shift+enter, and the output below matches the comment to the right of our code, we did it correctly." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Get going with strings" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "First use the `title` method to capitalize the first letter of each word in \"art vandelay\"`." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Art Vandelay'" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\".title() # 'Art Vandelay'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now let's uppercase all of the letters of \"Ceo\"." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'CEO'" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"Ceo\".upper() # 'CEO'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Next, write a method that answers a question about our email addresses. Every email address should end with \".com\". We can use our knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. " - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art.vandelay@vandelay.co\".endswith('.com') # False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. We can perform what is called string interpolation to fix this! Use the plus sign, `'+'`, to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'www.vandelay.com'" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'www.' + 'vandelay.com' # 'www.vandelay.com'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Working with numbers" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finally, Mr. Vandelay gave us his phone number, but he actually has two other phone numbers that are different from the one listed. All three numbers are basically the same with the excepion of the ending. Below, start by coercing the first phone number, which is currently a string, to an `int` and add one. Next do the same to the second phone number but increase it by two." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "7285553335" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "int(\"7285553334\") + 1 # 7285553335" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "7285553336" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "int(\"7285553334\") + 2 # 7285553336" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Summary" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Our first lab is done! Sweet. In this lab, we practiced working with string methods to operate on and answer questions about strings. We wrote methods that return Booleans and changed strings to intergers in order to perform addition. So much of working with data is ensuring that it is properly formatted so we can then operate on it, and in this lab, we saw how to use code to do just that." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "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.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} +{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'art vandelay'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\" # \"ART VANDELAY\""]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `uppercase` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 7, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["7285553335"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["int(\"7285553334\") + 1 # 7285553335"]}, {"cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [{"data": {"text/plain": ["7285553336"]}, "execution_count": 9, "metadata": {}, "output_type": "execute_result"}], "source": ["int(\"7285553334\") + 2 # 7285553336"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.5"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file From 7d61ea8d3bd65d3ddf817661575d0c6560565000 Mon Sep 17 00:00:00 2001 From: "matthew.mitchell" Date: Thu, 23 May 2019 15:35:43 -0400 Subject: [PATCH 08/12] Updating solutions --- README.md | 13 +- index.ipynb | 344 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 350 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5e3657b68d..7ba61d4f9f 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,14 @@ Here's a simple example of how you might go about doing this: ```python -"art vandelay" # "ART VANDELAY" +name = "art vandelay" # "ART VANDELAY" +name.upper() ``` - 'art vandelay' + 'ART VANDELAY' @@ -119,25 +120,25 @@ Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecti ```python -int("7285553334") + 1 # 7285553335 +"7285553334"[:3] # 728 ``` - 7285553335 + '728' ```python -int("7285553334") + 2 # 7285553336 +"7285553334"[:3] # 728 ``` - 7285553336 + '728' diff --git a/index.ipynb b/index.ipynb index 3707a09e87..daa9bdcaa9 100644 --- a/index.ipynb +++ b/index.ipynb @@ -1 +1,343 @@ -{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'art vandelay'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\" # \"ART VANDELAY\""]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `uppercase` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 7, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["7285553335"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["int(\"7285553334\") + 1 # 7285553335"]}, {"cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [{"data": {"text/plain": ["7285553336"]}, "execution_count": 9, "metadata": {}, "output_type": "execute_result"}], "source": ["int(\"7285553334\") + 2 # 7285553336"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.5"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Practice with Data Types" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Introduction" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", + "\n", + "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Learning Objectives\n", + "* Manipulate strings with built-in methods\n", + "* Practice coercing data types and changing numbers" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Here to mingle " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The next morning you take out the business card, ready to format it using your programming skills, and here is what we find." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### String Transformations" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", + "\n", + "Here's a simple example of how you might go about doing this:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ART VANDELAY'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "name = \"art vandelay\" # \"ART VANDELAY\"\n", + "name.upper()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'hello' ### whattttt" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get going with strings\n", + "\n", + "With that, use the appropriate string method to transform each string to match the desired output in the comment." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Art Vandelay'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"art vandelay\".title() # 'Art Vandelay'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now use the `uppercase` method to capitalize all of the letters of \"Ceo\"." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'CEO'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"Ceo\".upper() # 'CEO'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"art.vandelay@vandelay.co\".endswith('.com') # False" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'www.vandelay.com'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'www.' + 'vandelay.com' # 'www.vandelay.com'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### String Slicing" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'728'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"7285553334\"[:3] # 728" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'728'" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"7285553334\"[:3] # 728" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Summary" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "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.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 4eae037579cd4c2eb908e098f7475b75e99546fa Mon Sep 17 00:00:00 2001 From: Matt Stetz Date: Tue, 3 Sep 2019 18:09:06 -0400 Subject: [PATCH 09/12] correct method --- .learn | 1 + CONTRIBUTING.md | 37 ++++ LICENSE.md | 23 +++ README.md | 2 +- future_tests/index_test.py | 6 + index.ipynb | 344 +------------------------------------ 6 files changed, 69 insertions(+), 344 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 future_tests/index_test.py diff --git a/.learn b/.learn index cf225c9611..a654371e16 100644 --- a/.learn +++ b/.learn @@ -1,4 +1,5 @@ jupyter_notebook: true + tags: - jupyter - python diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..dd12a2a469 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +# Contributing to Learn.co Curriculum + +We're really exited that you're about to contribute to the [open curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). If this is your first time contributing, please continue reading to learn how to make the most meaningful and useful impact possible. + +## Raising an Issue to Encourage a Contribution + +If you notice a problem with the curriculum that you believe needs improvement +but you're unable to make the change yourself, you should raise a Github issue +containing a clear description of the problem. Include relevant snippets of +the content and/or screenshots if applicable. Curriculum owners regularly review +issue lists and your issue will be prioritized and addressed as appropriate. + +## Submitting a Pull Request to Suggest an Improvement + +If you see an opportunity for improvement and can make the change yourself go +ahead and use a typical git workflow to make it happen: + +* Fork this curriculum repository +* Make the change on your fork, with descriptive commits in the standard format +* Open a Pull Request against this repo + +A curriculum owner will review your change and approve or comment on it in due +course. + +# Why Contribute? + +Curriculum on Learn is publicly and freely available under Learn's +[Educational Content License](https://learn.co/content-license). By +embracing an open-source contribution model, our goal is for the curriculum +on Learn to become, in time, the best educational content the world has +ever seen. + +We need help from the community of Learners to maintain and improve the +educational content. Everything from fixing typos, to correcting +out-dated information, to improving exposition, to adding better examples, +to fixing tests—all contributions to making the curriculum more effective are +welcome. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000000..a297d511e1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,23 @@ +# Learn.co Educational Content License + +Copyright (c) 2018 Flatiron School, Inc + +The Flatiron School, Inc. owns this Educational Content. However, the Flatiron +School supports the development and availability of educational materials in +the public domain. Therefore, the Flatiron School grants Users of the Flatiron +Educational Content set forth in this repository certain rights to reuse, build +upon and share such Educational Content subject to the terms of the Educational +Content License set forth [here](http://learn.co/content-license) +(http://learn.co/content-license). You must read carefully the terms and +conditions contained in the Educational Content License as such terms govern +access to and use of the Educational Content. + +Flatiron School is willing to allow you access to and use of the Educational +Content only on the condition that you accept all of the terms and conditions +contained in the Educational Content License set forth +[here](http://learn.co/content-license) (http://learn.co/content-license). By +accessing and/or using the Educational Content, you are agreeing to all of the +terms and conditions contained in the Educational Content License. If you do +not agree to any or all of the terms of the Educational Content License, you +are prohibited from accessing, reviewing or using in any way the Educational +Content. diff --git a/README.md b/README.md index 7ba61d4f9f..9a4ace6506 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Use the `title` method to capitalize the first letter of each word in "art vande -Now use the `uppercase` method to capitalize all of the letters of "Ceo". +Now use the `upper` method to capitalize all of the letters of "Ceo". ```python diff --git a/future_tests/index_test.py b/future_tests/index_test.py new file mode 100644 index 0000000000..f2f81a901c --- /dev/null +++ b/future_tests/index_test.py @@ -0,0 +1,6 @@ +import unittest2 as unittest +from ipynb.fs.full.index import * + +class TestPythonDatatypes(unittest.TestCase): + def test_passes(self): + self.assertEqual(True, True) diff --git a/index.ipynb b/index.ipynb index daa9bdcaa9..d4f63db145 100644 --- a/index.ipynb +++ b/index.ipynb @@ -1,343 +1 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Practice with Data Types" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Introduction" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", - "\n", - "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives\n", - "* Manipulate strings with built-in methods\n", - "* Practice coercing data types and changing numbers" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Here to mingle " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The next morning you take out the business card, ready to format it using your programming skills, and here is what we find." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Transformations" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", - "\n", - "Here's a simple example of how you might go about doing this:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'ART VANDELAY'" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "name = \"art vandelay\" # \"ART VANDELAY\"\n", - "name.upper()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'hello'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'hello' ### whattttt" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Get going with strings\n", - "\n", - "With that, use the appropriate string method to transform each string to match the desired output in the comment." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Art Vandelay'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art vandelay\".title() # 'Art Vandelay'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now use the `uppercase` method to capitalize all of the letters of \"Ceo\"." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'CEO'" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"Ceo\".upper() # 'CEO'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. " - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"art.vandelay@vandelay.co\".endswith('.com') # False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'www.vandelay.com'" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'www.' + 'vandelay.com' # 'www.vandelay.com'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Slicing" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'728'" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"7285553334\"[:3] # 728" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'728'" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\"7285553334\"[:3] # 728" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Summary" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "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.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} +{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.6"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file From 1d3de0724f34c753c86ac6ebd3f52acd94bd16b8 Mon Sep 17 00:00:00 2001 From: Matt Stetz Date: Mon, 16 Sep 2019 14:09:18 -0400 Subject: [PATCH 10/12] typo --- README.md | 2 +- index.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a4ace6506..8bb1d34680 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### Introduction -In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action. +In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action. Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. diff --git a/index.ipynb b/index.ipynb index d4f63db145..2ba1cb5523 100644 --- a/index.ipynb +++ b/index.ipynb @@ -1 +1 @@ -{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons,you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.6"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file +{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.7.3"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file From 644c93b079c58d1e636a5bb7292f96c2cafc2753 Mon Sep 17 00:00:00 2001 From: "taylor.hawks" Date: Thu, 26 Sep 2019 11:38:16 -0400 Subject: [PATCH 11/12] minor changes for redeployment --- README.md | 2 +- index.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8bb1d34680..4191cfe1b3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action. -Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. +Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. ### Learning Objectives * Manipulate strings with built-in methods diff --git a/index.ipynb b/index.ipynb index 2ba1cb5523..186a6a0ff2 100644 --- a/index.ipynb +++ b/index.ipynb @@ -1 +1 @@ -{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.7.3"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file +{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.8"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file From 9e99ce34abcab76e49c2e6273c16734932769c9b Mon Sep 17 00:00:00 2001 From: Lore Dirick Date: Tue, 29 Oct 2019 15:31:40 -0400 Subject: [PATCH 12/12] minor changes for redeployment --- README.md | 26 +++++++------------------- index.ipynb | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 4191cfe1b3..bf9b1a5ecc 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ # Practice with Data Types -### Introduction +## Introduction In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action. Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. -### Learning Objectives +## Learning Objectives * Manipulate strings with built-in methods * Practice coercing data types and changing numbers -### Here to mingle +## Here to mingle The next morning you take out the business card, ready to format it using your programming skills, and here is what we find. ![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg) -### String Transformations +## String Transformations When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. @@ -54,7 +54,7 @@ Another important note is the hashtag `#`. In python, hashtags indicate a commen After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code. -### Get going with strings +## Get going with strings With that, use the appropriate string method to transform each string to match the desired output in the comment. @@ -114,7 +114,7 @@ As you can see below, the website "vandelay.com" is not preceded by `"www."`. Yo -### String Slicing +## String Slicing Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```"George"[:4]``` which would return ```"Geor"```. @@ -130,18 +130,6 @@ Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecti - -```python -"7285553334"[:3] # 728 -``` - - - - - '728' - - - -### Summary +## Summary Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills. diff --git a/index.ipynb b/index.ipynb index 186a6a0ff2..4fb3631784 100644 --- a/index.ipynb +++ b/index.ipynb @@ -1 +1 @@ -{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.8"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file +{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Practice with Data Types"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the past few lessons, you learned about working with different types of data in Python: strings, numbers (ints and floats), and booleans. Now, you'll put that knowledge into action.\n", "\n", "Imagine that you're at a business event and exchanged business cards with a few people. One of the business cards belongs to Art Vandelay, a new travel agent. Here, you'll use your programming skills to format this information correctly. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Learning Objectives\n", "* Manipulate strings with built-in methods\n", "* Practice coercing data types and changing numbers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Here to mingle "]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."]}, {"cell_type": "markdown", "metadata": {}, "source": ["![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## String Transformations"]}, {"cell_type": "markdown", "metadata": {}, "source": ["When storing text in a spreadsheet or database programmatically, you will often preprocess the data to ensure that it is properly formatted. For example, you might ensure that a telephone number matches the required format, or that a field on a web form is filled out. \n", "\n", "Here's a simple example of how you might go about doing this:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [{"data": {"text/plain": ["'ART VANDELAY'"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["name = \"art vandelay\" # \"ART VANDELAY\"\n", "name.upper()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you haven't already, put your cursor into the cell above and press `shift + enter` to run the code in the cell. You should see an updated output produced by the `.upper()` string method. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Another important note is the hashtag `#`. In python, hashtags indicate a comment. Comments are notes used to provide additional information but are ignored by the computer when running the code. "]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/plain": ["'hello'"]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["'hello' ### whattttt"]}, {"cell_type": "markdown", "metadata": {}, "source": ["After pressing shift+enter on the cell above, you'll see that Python ignores the comment. In Flatiron coding labs, a comment will be provided to indicate what you are aiming to have the code return. This allows you to then easily check your answer upon running your code."]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Get going with strings\n", "\n", "With that, use the appropriate string method to transform each string to match the desired output in the comment."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [{"data": {"text/plain": ["'Art Vandelay'"]}, "execution_count": 3, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art vandelay\".title() # 'Art Vandelay'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Now use the `upper` method to capitalize all of the letters of \"Ceo\"."]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/plain": ["'CEO'"]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["\"Ceo\".upper() # 'CEO'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Next, write a method that verifies whether an email addresses is valid. To make this introductory example simple, assume that every email address should end with \".com\". With that, use your knowledge of string methods to check if the email address ends with \".com\" and return `True` or `False` accordingly. "]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/plain": ["False"]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["\"art.vandelay@vandelay.co\".endswith('.com') # False"]}, {"cell_type": "markdown", "metadata": {}, "source": ["As you can see below, the website \"vandelay.com\" is not preceded by `\"www.\"`. You can perform string concatenation to fix this! string concatenation allows you to join two strings. It works just like numerical addition. For example, ```\"This is the start\" + \"and this is the end\"``` would return ```\"This is the start and this is the end\"```. Use string concatenation to change the website `'vandelay.com'` to the string `'www.vandelay.com'` by prepending `'www.'`."]}, {"cell_type": "code", "execution_count": 6, "metadata": {"scrolled": true}, "outputs": [{"data": {"text/plain": ["'www.vandelay.com'"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["'www.' + 'vandelay.com' # 'www.vandelay.com'"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## String Slicing"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Finally, Mr. Vandelay gave us his phone number. Extract the area code by selecting the first three characters of the string. You can do this using brackets to select characters from the string as in ```\"George\"[:4]``` which would return ```\"Geor\"```."]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/plain": ["'728'"]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["\"7285553334\"[:3] # 728"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Summary"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Congratulations! You just completed your first lab! You practiced working with string methods to operate on and answer questions about strings. You also used methods that return Booleans and sliced strings. So much of working with data is ensuring that it is properly formatted and in this lab, you started practicing your data wrangling skills."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "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.6"}}, "nbformat": 4, "nbformat_minor": 2} \ No newline at end of file