Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function pirate (e) that translates from English to Pirate, using following dictionary; those words that are not in the dictionary should remain unchanged:

Write a function pirate (e) that translates from English to Pirate, using following dictionary; those words that are not in the dictionary should remain unchanged:

You may assume that the input consists only of lowercase characters. When translating, replace only whole words, like sir or phrases, like how far, but not, for example, sir in desire. For this, consider all characters that are not letters to be separators (for example punctuation). In Python, all characters between 'a' and 'z' are letters, so everything less than 'a' or greater than 'z' is a separator. The same word or phrase can appear multiple times in a sentence, but be careful to avoid translating a translation: pardon my officer should become pardon me foul blaggart and pardon me should not be translated further.

d = {"hello": "ahoy", "hi": "yo-ho-ho", "pardon me": "avast", \ "excuse me": "arrr", "my": "me", "friend": "me bucko", "sir": "matey", "stranger": "scurvy dog", "officer": "foul blaggart",\ "where": "whar", "is": "be", "the": "th"", "you": "ye", \ "tell": "be tellin'", "know": "be knowin'", \ "how far": "how many leagues", "old": "barnacle-covered", \ "attractive": "comely", "happy": "grog-filled", \ "nearby": "broadside", "restroom": "head", "restaurant": "galley", "hotel": "fleabag inn", "pub": "Skull & Scuppers", "bank": "buried treasure"} >>> pirate ('excuse me, sir, do you know how far the old restaurant is?') "arrr, matey, do ye be knowin' how many leagues th' barnacle-covered galley be?" >>> pirate ('tell me officer, where is a nearby bank?') "be tellin' me foul blaggart, whar be a broadside buried treasure?"

Step by Step Solution

3.29 Rating (161 Votes )

There are 3 Steps involved in it

Step: 1

Explanation For every key array ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Document Format ( 2 attachments)

PDF file Icon
609350e4a335a_23670.pdf

180 KBs PDF File

Word file Icon
609350e4a335a_23670.docx

120 KBs Word File

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International financial management

Authors: Jeff Madura

12th edition

1133947832, 978-1305195011, 978-1133947837

More Books

Students also viewed these Programming questions

Question

How can you avoid confusing words that sound or seem similar?

Answered: 1 week ago

Question

Describe the major trends shaping franchising.

Answered: 1 week ago

Question

What are the APPROACHES TO HRM?

Answered: 1 week ago

Question

What do you mean by dual mode operation?

Answered: 1 week ago

Question

Explain the difference between `==` and `===` in JavaScript.

Answered: 1 week ago

Question

Subtract the polynomials. (-x+x-5) - (x-x + 5)

Answered: 1 week ago