|
209 | 209 | "words = {\n", |
210 | 210 | " 'gato': \"cat\",\n", |
211 | 211 | " 'casa': \"house\",\n", |
212 | | - " 'comio': \"ate\",\n", |
213 | 212 | " 'esta': \"is\",\n", |
214 | 213 | " 'en': \"in\",\n", |
215 | 214 | " 'el': \"the\",\n", |
|
247 | 246 | "metadata": {}, |
248 | 247 | "outputs": [] |
249 | 248 | }, |
| 249 | + { |
| 250 | + "cell_type": "markdown", |
| 251 | + "metadata": {}, |
| 252 | + "source": [ |
| 253 | + "We can also reassign keys in our dictionary:" |
| 254 | + ] |
| 255 | + }, |
| 256 | + { |
| 257 | + "cell_type": "code", |
| 258 | + "collapsed": false, |
| 259 | + "input": [ |
| 260 | + "words['gato'] = \"dog\"\n", |
| 261 | + "words['gato']" |
| 262 | + ], |
| 263 | + "language": "python", |
| 264 | + "metadata": {}, |
| 265 | + "outputs": [] |
| 266 | + }, |
| 267 | + { |
| 268 | + "cell_type": "markdown", |
| 269 | + "metadata": {}, |
| 270 | + "source": [ |
| 271 | + "Let's change that back so we don't confuse anyone:" |
| 272 | + ] |
| 273 | + }, |
| 274 | + { |
| 275 | + "cell_type": "code", |
| 276 | + "collapsed": false, |
| 277 | + "input": [ |
| 278 | + "words['gato'] = \"cat\"" |
| 279 | + ], |
| 280 | + "language": "python", |
| 281 | + "metadata": {}, |
| 282 | + "outputs": [] |
| 283 | + }, |
250 | 284 | { |
251 | 285 | "cell_type": "markdown", |
252 | 286 | "metadata": {}, |
|
342 | 376 | "words = {\n", |
343 | 377 | " 'gato': \"cat\",\n", |
344 | 378 | " 'casa': \"house\",\n", |
345 | | - " 'comio': \"ate\",\n", |
346 | 379 | " 'esta': \"is\",\n", |
347 | 380 | " 'en': \"in\",\n", |
348 | 381 | " 'el': \"the\",\n", |
|
364 | 397 | "cell_type": "code", |
365 | 398 | "collapsed": false, |
366 | 399 | "input": [ |
367 | | - "translate(\"el gato comio la casa\")" |
| 400 | + "translate(\"el gato esta en la casa\")" |
368 | 401 | ], |
369 | 402 | "language": "python", |
370 | 403 | "metadata": {}, |
|
374 | 407 | "cell_type": "markdown", |
375 | 408 | "metadata": {}, |
376 | 409 | "source": [ |
377 | | - "Now let's make the words dictionary a Spain Spanish and Mexican Spanish to English dictionary. We'll start by adding a few keys and values." |
| 410 | + "Let's add another word to our dictionary:" |
378 | 411 | ] |
379 | 412 | }, |
380 | 413 | { |
381 | 414 | "cell_type": "code", |
382 | 415 | "collapsed": false, |
383 | 416 | "input": [ |
384 | | - "words['patatas'] = 'potatoes'\n", |
385 | | - "words['papas'] = 'potatoes'\n", |
386 | | - "words['zumo'] = 'juice'\n", |
387 | | - "words['jugo'] = 'juice'\n", |
388 | | - "words['y'] = 'and'\n", |
389 | | - "words['comio'] = 'ate'\n", |
390 | | - "words['bebi\u00f3'] = 'drank'\n", |
391 | | - "words['las'] = 'the'\n", |
392 | | - "words['galletas'] = 'cookies'\n", |
393 | | - "words['papas-fritas'] = 'french fries'\n", |
394 | | - "words['patatas-fritas'] = 'french fries'" |
| 417 | + "words['jugo'] = \"juice\"" |
395 | 418 | ], |
396 | 419 | "language": "python", |
397 | 420 | "metadata": {}, |
398 | 421 | "outputs": [] |
399 | 422 | }, |
400 | | - { |
401 | | - "cell_type": "markdown", |
402 | | - "metadata": {}, |
403 | | - "source": [ |
404 | | - "Mexican Spanish to English translation:" |
405 | | - ] |
406 | | - }, |
407 | 423 | { |
408 | 424 | "cell_type": "code", |
409 | 425 | "collapsed": false, |
410 | 426 | "input": [ |
411 | | - "translate(\"el gato bebi\u00f3 el jugo y comio las papas\")" |
| 427 | + "translate(\"el jugo esta en la casa\")" |
412 | 428 | ], |
413 | 429 | "language": "python", |
414 | 430 | "metadata": {}, |
|
418 | 434 | "cell_type": "markdown", |
419 | 435 | "metadata": {}, |
420 | 436 | "source": [ |
421 | | - "Spain Spanish to English translation:" |
| 437 | + "That's how we say juice in Mexican Spanish but what if we're traveling to Spain? Let's remove jugo from our dictionary and add zumo:" |
422 | 438 | ] |
423 | 439 | }, |
424 | 440 | { |
425 | 441 | "cell_type": "code", |
426 | 442 | "collapsed": false, |
427 | 443 | "input": [ |
428 | | - "translate(\"el gato bebi\u00f3 el zumo y comio las patatas\")" |
| 444 | + "del words['jugo']\n", |
| 445 | + "words['zumo'] = \"juice\"" |
429 | 446 | ], |
430 | 447 | "language": "python", |
431 | 448 | "metadata": {}, |
|
435 | 452 | "cell_type": "markdown", |
436 | 453 | "metadata": {}, |
437 | 454 | "source": [ |
438 | | - "To illustrate a few more dictionary concepts, let's convert our dictionary to Span Spanish to British English." |
| 455 | + "Let's try our Mexican Spanish sentence again. What should happen?" |
439 | 456 | ] |
440 | 457 | }, |
441 | 458 | { |
442 | 459 | "cell_type": "code", |
443 | 460 | "collapsed": false, |
444 | 461 | "input": [ |
445 | | - "#remove the Mexican Spanish key, values:\n", |
446 | | - "del words['papas']\n", |
447 | | - "del words['jugo']\n", |
448 | | - "del words['papas-fritas']" |
| 462 | + "translate(\"el jugo esta en la casa\")" |
449 | 463 | ], |
450 | 464 | "language": "python", |
451 | 465 | "metadata": {}, |
452 | 466 | "outputs": [] |
453 | 467 | }, |
454 | 468 | { |
455 | | - "cell_type": "code", |
456 | | - "collapsed": false, |
457 | | - "input": [ |
458 | | - "#change the values from English to British English:\n", |
459 | | - "words['galletas'] = 'bisquits'\n", |
460 | | - "words['patatas-fritas'] = 'chips'" |
461 | | - ], |
462 | | - "language": "python", |
| 469 | + "cell_type": "markdown", |
463 | 470 | "metadata": {}, |
464 | | - "outputs": [] |
| 471 | + "source": [ |
| 472 | + "Now let's try our Spanish Spanish sentence:" |
| 473 | + ] |
465 | 474 | }, |
466 | 475 | { |
467 | 476 | "cell_type": "code", |
468 | 477 | "collapsed": false, |
469 | 478 | "input": [ |
470 | | - "translate(\"el gato bebi\u00f3 el zumo y comio las patatas-fritas y las galletas\")" |
| 479 | + "translate(\"el zumo esta en la casa\")" |
471 | 480 | ], |
472 | 481 | "language": "python", |
473 | 482 | "metadata": {}, |
|
0 commit comments