We’re starting off with all the English words and Pirate words in two separate lists where the positions of the lists correspond.  It is associated lists like this work but when a mapping solution is required, dictionaries are often a more natural implementation. (a) Your first job is to redesign the approach and turn these two lists into one dictionary. The words, both English and Pirate language, are distinct, so either one can be the key. Here are the original lists (feel free to add your own words; we got them by googling “Pirate Talk”) ENGLISH = ['hello', 'friend', 'hey', 'awful', 'wow','reward', 'song', 'money',            'board', 'cocktail', 'bathroom', 'friends', 'cheat', 'flag','boy',            'girl', 'my', 'take', 'sink', 'telescope', 'clean', 'you'] PIRATE = ['ahoy', 'matey', 'avast', 'bilge-sucking', 'blimey', 'booty', 'chanty',           'dubloon', 'plank', 'grogg', 'head', 'hearties', 'hornswaggle',           'jack', 'lad', 'lass', 'me', 'plunder', 'scuttle', 'spyglass', 'swob',           'ye'] (b) Now that you have your dictionary set up, prompt the user for a sentence, and then translate from English into Pirate. Allow the user to enter upper or lowercase letters but assume no punctuation. Use a while loop to keep prompting for a sentence to translate until the user enters ‘arr’

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 17SA
icon
Related questions
Question

Simple Dictionaries: Pirate-Talk Translator

We’ll use a Python dictionary as an actual dictionary. As we discussed in our lecture this week, a dictionary is really good for 1-1 mapping of concepts-to-values, so that's what we'll do here.

We’re starting off with all the English words and Pirate words in two separate lists where the positions of the lists correspond.  It is associated lists like this work but when a mapping solution is required, dictionaries are often a more natural implementation.

(a) Your first job is to redesign the approach and turn these two lists into one dictionary. The words, both English and Pirate language, are distinct, so either one can be the key.

Here are the original lists (feel free to add your own words; we got them by googling “Pirate Talk”)

ENGLISH = ['hello', 'friend', 'hey', 'awful', 'wow','reward', 'song', 'money',

           'board', 'cocktail', 'bathroom', 'friends', 'cheat', 'flag','boy',

           'girl', 'my', 'take', 'sink', 'telescope', 'clean', 'you']

PIRATE = ['ahoy', 'matey', 'avast', 'bilge-sucking', 'blimey', 'booty', 'chanty',

          'dubloon', 'plank', 'grogg', 'head', 'hearties', 'hornswaggle',

          'jack', 'lad', 'lass', 'me', 'plunder', 'scuttle', 'spyglass', 'swob',

          'ye']

(b) Now that you have your dictionary set up, prompt the user for a sentence, and then translate from English into Pirate. Allow the user to enter upper or lowercase letters but assume no punctuation. Use a while loop to keep prompting for a sentence to translate until the user enters ‘arr’.

Here's an example of running this one:
RESTART: /Users/keithbagley/Dropbox/NORTHEASTERN
Arrrrr welcome to me pirate dictionary!
Type some stuff, then hit enter with yer sword.
Or just say 'arr' to be done, ya scalliwag.
hello my friends
ahoy me hearties
Type some stuff, then hit enter with yer Sword.
Or just say 'arr' to be done, ya scalliwag.
Wow this cocktail is awful
blimey this grogg is bilge-sucking
Type some stuff, then hit enter with yer sword.
Or just say 'arr' to be done, ya scalliwag.
sing me a song while you clean the bathroom
sing me a chanty while ye swob the head
Type some stuff, then hit enter with yer sword.
Or just say 'arr' to be done, ya scalliwag.
arr
>>>
Transcribed Image Text:Here's an example of running this one: RESTART: /Users/keithbagley/Dropbox/NORTHEASTERN Arrrrr welcome to me pirate dictionary! Type some stuff, then hit enter with yer sword. Or just say 'arr' to be done, ya scalliwag. hello my friends ahoy me hearties Type some stuff, then hit enter with yer Sword. Or just say 'arr' to be done, ya scalliwag. Wow this cocktail is awful blimey this grogg is bilge-sucking Type some stuff, then hit enter with yer sword. Or just say 'arr' to be done, ya scalliwag. sing me a song while you clean the bathroom sing me a chanty while ye swob the head Type some stuff, then hit enter with yer sword. Or just say 'arr' to be done, ya scalliwag. arr >>>
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning