Skip to content

Commit 4930882

Browse files
committed
Merge pull request #36 from pythonsd/food_dictionary
added alain's suggested dictionary examples
2 parents 8edb227 + 63c195d commit 4930882

File tree

1 file changed

+139
-2
lines changed

1 file changed

+139
-2
lines changed

part-4.ipynb

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"metadata": {
33
"name": "",
4-
"signature": "sha256:40f96dd4a9a68767b80bf16809c2b3aebd08f6893eb2d01994fd18e611864f26"
4+
"signature": "sha256:c41c7b2462d1eccc5d63748331ca0f9ee5635e45f1f51c325d9a923cc48cc7ad"
55
},
66
"nbformat": 3,
77
"nbformat_minor": 0,
@@ -360,7 +360,8 @@
360360
],
361361
"language": "python",
362362
"metadata": {},
363-
"outputs": []
363+
"outputs": [],
364+
"prompt_number": 2
364365
},
365366
{
366367
"cell_type": "code",
@@ -392,6 +393,142 @@
392393
"metadata": {},
393394
"outputs": []
394395
},
396+
{
397+
"cell_type": "markdown",
398+
"metadata": {},
399+
"source": [
400+
"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."
401+
]
402+
},
403+
{
404+
"cell_type": "code",
405+
"collapsed": false,
406+
"input": [
407+
"words['patatas'] = 'potatoes'\n",
408+
"words['papas'] = 'potatoes'\n",
409+
"words['zumo'] = 'juice'\n",
410+
"words['jugo'] = 'juice'\n",
411+
"words['y'] = 'and'\n",
412+
"words['comio'] = 'ate'\n",
413+
"words['bebi\u00f3'] = 'drank'\n",
414+
"words['las'] = 'the'\n",
415+
"words['galletas'] = 'cookies'\n",
416+
"words['papas-fritas'] = 'french fries'\n",
417+
"words['patatas-fritas'] = 'french fries'"
418+
],
419+
"language": "python",
420+
"metadata": {},
421+
"outputs": [],
422+
"prompt_number": 17
423+
},
424+
{
425+
"cell_type": "markdown",
426+
"metadata": {},
427+
"source": [
428+
"Mexican Spanish to English translation:"
429+
]
430+
},
431+
{
432+
"cell_type": "code",
433+
"collapsed": false,
434+
"input": [
435+
"translate(\"el perro bebi\u00f3 el jugo y comio las papas\")"
436+
],
437+
"language": "python",
438+
"metadata": {},
439+
"outputs": [
440+
{
441+
"metadata": {},
442+
"output_type": "pyout",
443+
"prompt_number": 8,
444+
"text": [
445+
"'the dog drank the juice and ate the potatoes'"
446+
]
447+
}
448+
],
449+
"prompt_number": 8
450+
},
451+
{
452+
"cell_type": "markdown",
453+
"metadata": {},
454+
"source": [
455+
"Spain Spanish to English translation:"
456+
]
457+
},
458+
{
459+
"cell_type": "code",
460+
"collapsed": false,
461+
"input": [
462+
"translate(\"el perro bebi\u00f3 el zumo y comio las patatas\")"
463+
],
464+
"language": "python",
465+
"metadata": {},
466+
"outputs": [
467+
{
468+
"metadata": {},
469+
"output_type": "pyout",
470+
"prompt_number": 11,
471+
"text": [
472+
"'the dog drank the juice and ate the potatoes'"
473+
]
474+
}
475+
],
476+
"prompt_number": 11
477+
},
478+
{
479+
"cell_type": "markdown",
480+
"metadata": {},
481+
"source": [
482+
"To illustrate a few more dictionary concepts, let's convert our dictionary to Span Spanish to British English."
483+
]
484+
},
485+
{
486+
"cell_type": "code",
487+
"collapsed": false,
488+
"input": [
489+
"#remove the Mexican Spanish key, values:\n",
490+
"del words['papas']\n",
491+
"del words['jugo']\n",
492+
"del words['papas-fritas']"
493+
],
494+
"language": "python",
495+
"metadata": {},
496+
"outputs": [],
497+
"prompt_number": 18
498+
},
499+
{
500+
"cell_type": "code",
501+
"collapsed": false,
502+
"input": [
503+
"#change the values from English to British English:\n",
504+
"words['galletas'] = 'bisquits'\n",
505+
"words['patatas-fritas'] = 'chips'"
506+
],
507+
"language": "python",
508+
"metadata": {},
509+
"outputs": [],
510+
"prompt_number": 22
511+
},
512+
{
513+
"cell_type": "code",
514+
"collapsed": false,
515+
"input": [
516+
"translate(\"el perro bebi\u00f3 el zumo y comio las patatas-fritas y las galletas\")"
517+
],
518+
"language": "python",
519+
"metadata": {},
520+
"outputs": [
521+
{
522+
"metadata": {},
523+
"output_type": "pyout",
524+
"prompt_number": 25,
525+
"text": [
526+
"'the dog drank the juice and ate the chips and the bisquits'"
527+
]
528+
}
529+
],
530+
"prompt_number": 25
531+
},
395532
{
396533
"cell_type": "markdown",
397534
"metadata": {},

0 commit comments

Comments
 (0)