Skip to content

Commit 4cb6511

Browse files
author
Matt Stetz
committed
correct method
1 parent 057fc3d commit 4cb6511

File tree

2 files changed

+2
-271
lines changed

2 files changed

+2
-271
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Use the `title` method to capitalize the first letter of each word in "art vande
5151
"art vandelay" # 'Art Vandelay'
5252
```
5353

54-
Now use the `uppercase` method to capitalize all of the letters of "Ceo".
54+
Now use the `upper` method to capitalize all of the letters of "Ceo".
5555

5656

5757
```python

index.ipynb

Lines changed: 1 addition & 270 deletions
Original file line numberDiff line numberDiff line change
@@ -1,270 +1 @@
1-
{
2-
"cells": [
3-
{
4-
"cell_type": "markdown",
5-
"metadata": {},
6-
"source": [
7-
"# Practice with Data Types"
8-
]
9-
},
10-
{
11-
"cell_type": "markdown",
12-
"metadata": {},
13-
"source": [
14-
"### Introduction"
15-
]
16-
},
17-
{
18-
"cell_type": "markdown",
19-
"metadata": {},
20-
"source": [
21-
"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",
22-
"\n",
23-
"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. "
24-
]
25-
},
26-
{
27-
"cell_type": "markdown",
28-
"metadata": {},
29-
"source": [
30-
"### Learning Objectives\n",
31-
"* Manipulate strings with built-in methods\n",
32-
"* Practice coercing data types and changing numbers"
33-
]
34-
},
35-
{
36-
"cell_type": "markdown",
37-
"metadata": {},
38-
"source": [
39-
"### Here to mingle "
40-
]
41-
},
42-
{
43-
"cell_type": "markdown",
44-
"metadata": {},
45-
"source": [
46-
"The next morning you take out the business card, ready to format it using your programming skills, and here is what we find."
47-
]
48-
},
49-
{
50-
"cell_type": "markdown",
51-
"metadata": {},
52-
"source": [
53-
"![](https://learn-verified.s3.amazonaws.com/data-science-assets/biz-card-mistakes.jpg)"
54-
]
55-
},
56-
{
57-
"cell_type": "markdown",
58-
"metadata": {},
59-
"source": [
60-
"### String Transformations"
61-
]
62-
},
63-
{
64-
"cell_type": "markdown",
65-
"metadata": {},
66-
"source": [
67-
"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",
68-
"\n",
69-
"Here's a simple example of how you might go about doing this:"
70-
]
71-
},
72-
{
73-
"cell_type": "code",
74-
"execution_count": null,
75-
"metadata": {
76-
"collapsed": true
77-
},
78-
"outputs": [],
79-
"source": [
80-
"name = \"art vandelay\" # \"ART VANDELAY\"\n",
81-
"name.upper()"
82-
]
83-
},
84-
{
85-
"cell_type": "markdown",
86-
"metadata": {},
87-
"source": [
88-
"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. "
89-
]
90-
},
91-
{
92-
"cell_type": "markdown",
93-
"metadata": {},
94-
"source": [
95-
"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. "
96-
]
97-
},
98-
{
99-
"cell_type": "code",
100-
"execution_count": null,
101-
"metadata": {
102-
"collapsed": true
103-
},
104-
"outputs": [],
105-
"source": [
106-
"'hello' ### whattttt"
107-
]
108-
},
109-
{
110-
"cell_type": "markdown",
111-
"metadata": {},
112-
"source": [
113-
"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."
114-
]
115-
},
116-
{
117-
"cell_type": "markdown",
118-
"metadata": {},
119-
"source": [
120-
"### Get going with strings\n",
121-
"\n",
122-
"With that, use the appropriate string method to transform each string to match the desired output in the comment."
123-
]
124-
},
125-
{
126-
"cell_type": "markdown",
127-
"metadata": {},
128-
"source": [
129-
"Use the `title` method to capitalize the first letter of each word in \"art vandelay\"`."
130-
]
131-
},
132-
{
133-
"cell_type": "code",
134-
"execution_count": null,
135-
"metadata": {
136-
"collapsed": true
137-
},
138-
"outputs": [],
139-
"source": [
140-
"\"art vandelay\" # 'Art Vandelay'"
141-
]
142-
},
143-
{
144-
"cell_type": "markdown",
145-
"metadata": {},
146-
"source": [
147-
"Now use the `uppercase` method to capitalize all of the letters of \"Ceo\"."
148-
]
149-
},
150-
{
151-
"cell_type": "code",
152-
"execution_count": null,
153-
"metadata": {
154-
"collapsed": true
155-
},
156-
"outputs": [],
157-
"source": [
158-
"\"Ceo\" # 'CEO'"
159-
]
160-
},
161-
{
162-
"cell_type": "markdown",
163-
"metadata": {},
164-
"source": [
165-
"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. "
166-
]
167-
},
168-
{
169-
"cell_type": "code",
170-
"execution_count": null,
171-
"metadata": {
172-
"collapsed": true
173-
},
174-
"outputs": [],
175-
"source": [
176-
"\"art.vandelay@vandelay.co\" # False"
177-
]
178-
},
179-
{
180-
"cell_type": "markdown",
181-
"metadata": {},
182-
"source": [
183-
"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.'`."
184-
]
185-
},
186-
{
187-
"cell_type": "code",
188-
"execution_count": null,
189-
"metadata": {
190-
"collapsed": true,
191-
"scrolled": true
192-
},
193-
"outputs": [],
194-
"source": [
195-
"'vandelay.com' # 'www.vandelay.com'"
196-
]
197-
},
198-
{
199-
"cell_type": "markdown",
200-
"metadata": {},
201-
"source": [
202-
"### String Slicing"
203-
]
204-
},
205-
{
206-
"cell_type": "markdown",
207-
"metadata": {},
208-
"source": [
209-
"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\"```."
210-
]
211-
},
212-
{
213-
"cell_type": "code",
214-
"execution_count": null,
215-
"metadata": {
216-
"collapsed": true
217-
},
218-
"outputs": [],
219-
"source": [
220-
"\"7285553334\" # 728"
221-
]
222-
},
223-
{
224-
"cell_type": "code",
225-
"execution_count": null,
226-
"metadata": {
227-
"collapsed": true
228-
},
229-
"outputs": [],
230-
"source": [
231-
"\"7285553334\" # 728"
232-
]
233-
},
234-
{
235-
"cell_type": "markdown",
236-
"metadata": {},
237-
"source": [
238-
"### Summary"
239-
]
240-
},
241-
{
242-
"cell_type": "markdown",
243-
"metadata": {},
244-
"source": [
245-
"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."
246-
]
247-
}
248-
],
249-
"metadata": {
250-
"kernelspec": {
251-
"display_name": "Python 3",
252-
"language": "python",
253-
"name": "python3"
254-
},
255-
"language_info": {
256-
"codemirror_mode": {
257-
"name": "ipython",
258-
"version": 3
259-
},
260-
"file_extension": ".py",
261-
"mimetype": "text/x-python",
262-
"name": "python",
263-
"nbconvert_exporter": "python",
264-
"pygments_lexer": "ipython3",
265-
"version": "3.6.5"
266-
}
267-
},
268-
"nbformat": 4,
269-
"nbformat_minor": 2
270-
}
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": null, "metadata": {"collapsed": true}, "outputs": [], "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": null, "metadata": {"collapsed": true}, "outputs": [], "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": null, "metadata": {"collapsed": true}, "outputs": [], "source": ["\"art vandelay\" # '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": null, "metadata": {"collapsed": true}, "outputs": [], "source": ["\"Ceo\" # '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": null, "metadata": {"collapsed": true}, "outputs": [], "source": ["\"art.vandelay@vandelay.co\" # 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": null, "metadata": {"collapsed": true, "scrolled": true}, "outputs": [], "source": ["'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": null, "metadata": {"collapsed": true}, "outputs": [], "source": ["\"7285553334\" # 728"]}, {"cell_type": "code", "execution_count": null, "metadata": {"collapsed": true}, "outputs": [], "source": ["\"7285553334\" # 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}

0 commit comments

Comments
 (0)