|
20 | 20 | "source": [
|
21 | 21 | "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",
|
22 | 22 | "\n",
|
23 |
| - "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. " |
| 23 | + "In this lesson we'll imagine that just met Art Vandelay, a CEO of his own travel agency, Vandelay Industries. He gave us his business card, and we would like to use our knowledge of strings to format his information properly before we file it away." |
24 | 24 | ]
|
25 | 25 | },
|
26 | 26 | {
|
|
57 | 57 | "cell_type": "markdown",
|
58 | 58 | "metadata": {},
|
59 | 59 | "source": [
|
60 |
| - "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", |
| 60 | + "Yea, he may not be our first choice, but we said he'd give us a discount so we move ahead. Plus his poor formatting on his card will give us practice with strings. \n", |
61 | 61 | "\n",
|
62 |
| - "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." |
| 62 | + "And we know that a lot of information online is mistyped. Just think of when all the times people misenter information on forms. So let's get to work." |
63 | 63 | ]
|
64 | 64 | },
|
65 | 65 | {
|
|
73 | 73 | "cell_type": "markdown",
|
74 | 74 | "metadata": {},
|
75 | 75 | "source": [
|
76 |
| - "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:" |
| 76 | + "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 like after you change it. Let's do the first one together. \n", |
| 77 | + "\n", |
| 78 | + "For example, let's say we want to capitalize all of the letters of \"art vandlay\". You'll see the following:" |
77 | 79 | ]
|
78 | 80 | },
|
79 | 81 | {
|
80 | 82 | "cell_type": "code",
|
81 |
| - "execution_count": 1, |
82 |
| - "metadata": {}, |
83 |
| - "outputs": [ |
84 |
| - { |
85 |
| - "data": { |
86 |
| - "text/plain": [ |
87 |
| - "'art vandelay'" |
88 |
| - ] |
89 |
| - }, |
90 |
| - "execution_count": 1, |
91 |
| - "metadata": {}, |
92 |
| - "output_type": "execute_result" |
93 |
| - } |
94 |
| - ], |
| 83 | + "execution_count": null, |
| 84 | + "metadata": {}, |
| 85 | + "outputs": [], |
95 | 86 | "source": [
|
96 | 87 | "\"art vandelay\" # 'ART VANDELAY'"
|
97 | 88 | ]
|
|
100 | 91 | "cell_type": "markdown",
|
101 | 92 | "metadata": {},
|
102 | 93 | "source": [
|
103 |
| - "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." |
| 94 | + "Notice that there is no output below the gray code below. This is because Jupyter notebooks do not automatically run our code - so they do not automatically know the output. To display the output, you must **run** the code by clicking on the gray cell and then pressing shift + enter. Try it above and you will see output below the cell." |
| 95 | + ] |
| 96 | + }, |
| 97 | + { |
| 98 | + "cell_type": "markdown", |
| 99 | + "metadata": {}, |
| 100 | + "source": [ |
| 101 | + "Ok, once you see the output take a look at the hash tag to the right of the string. The 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. See this by running the next cell below (again, press shift + enter)." |
104 | 102 | ]
|
105 | 103 | },
|
106 | 104 | {
|
107 | 105 | "cell_type": "code",
|
108 |
| - "execution_count": 2, |
109 |
| - "metadata": {}, |
110 |
| - "outputs": [ |
111 |
| - { |
112 |
| - "data": { |
113 |
| - "text/plain": [ |
114 |
| - "'hello'" |
115 |
| - ] |
116 |
| - }, |
117 |
| - "execution_count": 2, |
118 |
| - "metadata": {}, |
119 |
| - "output_type": "execute_result" |
120 |
| - } |
121 |
| - ], |
| 106 | + "execution_count": null, |
| 107 | + "metadata": {}, |
| 108 | + "outputs": [], |
122 | 109 | "source": [
|
123 | 110 | "'hello'\n",
|
124 | 111 | "### whattttt"
|
|
128 | 115 | "cell_type": "markdown",
|
129 | 116 | "metadata": {},
|
130 | 117 | "source": [
|
131 |
| - "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." |
| 118 | + "If you press shift+enter on the cell above to run the code, you will see that Python happily ignores the comment. So here (and in future labs), we will 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." |
132 | 119 | ]
|
133 | 120 | },
|
134 | 121 | {
|
|
142 | 129 | "cell_type": "markdown",
|
143 | 130 | "metadata": {},
|
144 | 131 | "source": [
|
145 |
| - "And change it to the following:" |
| 132 | + "So to get our output to match comment we change it to the following:" |
146 | 133 | ]
|
147 | 134 | },
|
148 | 135 | {
|
149 | 136 | "cell_type": "code",
|
150 |
| - "execution_count": 3, |
151 |
| - "metadata": {}, |
152 |
| - "outputs": [ |
153 |
| - { |
154 |
| - "data": { |
155 |
| - "text/plain": [ |
156 |
| - "'ART VANDELAY'" |
157 |
| - ] |
158 |
| - }, |
159 |
| - "execution_count": 3, |
160 |
| - "metadata": {}, |
161 |
| - "output_type": "execute_result" |
162 |
| - } |
163 |
| - ], |
| 137 | + "execution_count": null, |
| 138 | + "metadata": {}, |
| 139 | + "outputs": [], |
164 | 140 | "source": [
|
165 | 141 | "\"art vandelay\".upper() # 'ART VANDELAY'"
|
166 | 142 | ]
|
|
181 | 157 | },
|
182 | 158 | {
|
183 | 159 | "cell_type": "code",
|
184 |
| - "execution_count": 4, |
185 |
| - "metadata": {}, |
186 |
| - "outputs": [ |
187 |
| - { |
188 |
| - "data": { |
189 |
| - "text/plain": [ |
190 |
| - "'art vandelay'" |
191 |
| - ] |
192 |
| - }, |
193 |
| - "execution_count": 4, |
194 |
| - "metadata": {}, |
195 |
| - "output_type": "execute_result" |
196 |
| - } |
197 |
| - ], |
| 160 | + "execution_count": null, |
| 161 | + "metadata": {}, |
| 162 | + "outputs": [], |
198 | 163 | "source": [
|
199 | 164 | "\"art vandelay\" # 'Art Vandelay'"
|
200 | 165 | ]
|
|
208 | 173 | },
|
209 | 174 | {
|
210 | 175 | "cell_type": "code",
|
211 |
| - "execution_count": 5, |
212 |
| - "metadata": {}, |
213 |
| - "outputs": [ |
214 |
| - { |
215 |
| - "data": { |
216 |
| - "text/plain": [ |
217 |
| - "'Ceo'" |
218 |
| - ] |
219 |
| - }, |
220 |
| - "execution_count": 5, |
221 |
| - "metadata": {}, |
222 |
| - "output_type": "execute_result" |
223 |
| - } |
224 |
| - ], |
| 176 | + "execution_count": null, |
| 177 | + "metadata": {}, |
| 178 | + "outputs": [], |
225 | 179 | "source": [
|
226 | 180 | "\"Ceo\" # 'CEO'"
|
227 | 181 | ]
|
|
230 | 184 | "cell_type": "markdown",
|
231 | 185 | "metadata": {},
|
232 | 186 | "source": [
|
233 |
| - "Now write a method that answers 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. " |
| 187 | + "Next, write a method that answers 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. " |
234 | 188 | ]
|
235 | 189 | },
|
236 | 190 | {
|
237 | 191 | "cell_type": "code",
|
238 |
| - "execution_count": 6, |
| 192 | + "execution_count": null, |
239 | 193 | "metadata": {},
|
240 |
| - "outputs": [ |
241 |
| - { |
242 |
| - "data": { |
243 |
| - "text/plain": [ |
244 |
| - "'art.vandelay@vandelay.cop'" |
245 |
| - ] |
246 |
| - }, |
247 |
| - "execution_count": 6, |
248 |
| - "metadata": {}, |
249 |
| - "output_type": "execute_result" |
250 |
| - } |
251 |
| - ], |
| 194 | + "outputs": [], |
252 | 195 | "source": [
|
253 |
| - "\"art.vandelay@vandelay.cop\" # False" |
| 196 | + "\"art.vandelay@vandelay.co\" # False" |
254 | 197 | ]
|
255 | 198 | },
|
256 | 199 | {
|
|
262 | 205 | },
|
263 | 206 | {
|
264 | 207 | "cell_type": "code",
|
265 |
| - "execution_count": 7, |
| 208 | + "execution_count": null, |
266 | 209 | "metadata": {
|
267 | 210 | "scrolled": true
|
268 | 211 | },
|
269 |
| - "outputs": [ |
270 |
| - { |
271 |
| - "data": { |
272 |
| - "text/plain": [ |
273 |
| - "'vandelay.com'" |
274 |
| - ] |
275 |
| - }, |
276 |
| - "execution_count": 7, |
277 |
| - "metadata": {}, |
278 |
| - "output_type": "execute_result" |
279 |
| - } |
280 |
| - ], |
| 212 | + "outputs": [], |
281 | 213 | "source": [
|
282 | 214 | "'vandelay.com' # 'www.vandelay.com'"
|
283 | 215 | ]
|
|
298 | 230 | },
|
299 | 231 | {
|
300 | 232 | "cell_type": "code",
|
301 |
| - "execution_count": 8, |
302 |
| - "metadata": {}, |
303 |
| - "outputs": [ |
304 |
| - { |
305 |
| - "data": { |
306 |
| - "text/plain": [ |
307 |
| - "'7285553334'" |
308 |
| - ] |
309 |
| - }, |
310 |
| - "execution_count": 8, |
311 |
| - "metadata": {}, |
312 |
| - "output_type": "execute_result" |
313 |
| - } |
314 |
| - ], |
| 233 | + "execution_count": null, |
| 234 | + "metadata": {}, |
| 235 | + "outputs": [], |
315 | 236 | "source": [
|
316 | 237 | "\"7285553334\" # 7285553335"
|
317 | 238 | ]
|
318 | 239 | },
|
319 | 240 | {
|
320 | 241 | "cell_type": "code",
|
321 |
| - "execution_count": 9, |
322 |
| - "metadata": {}, |
323 |
| - "outputs": [ |
324 |
| - { |
325 |
| - "data": { |
326 |
| - "text/plain": [ |
327 |
| - "'7285553334'" |
328 |
| - ] |
329 |
| - }, |
330 |
| - "execution_count": 9, |
331 |
| - "metadata": {}, |
332 |
| - "output_type": "execute_result" |
333 |
| - } |
334 |
| - ], |
| 242 | + "execution_count": null, |
| 243 | + "metadata": {}, |
| 244 | + "outputs": [], |
335 | 245 | "source": [
|
336 | 246 | "\"7285553334\" # 7285553336"
|
337 | 247 | ]
|
|
367 | 277 | "name": "python",
|
368 | 278 | "nbconvert_exporter": "python",
|
369 | 279 | "pygments_lexer": "ipython3",
|
370 |
| - "version": "3.6.4" |
| 280 | + "version": "3.6.1" |
371 | 281 | }
|
372 | 282 | },
|
373 | 283 | "nbformat": 4,
|
|
0 commit comments