Question: Write a Python module called piglatin.py that contains functions for translating sentences between English and a variant of Pig Latin (see: http://en.wikipedia.org/wiki/Pig_Latin). To convert from

Write a Python module called piglatin.py that contains functions for translating sentences between English and a variant of Pig Latin (see: http://en.wikipedia.org/wiki/Pig_Latin).

To convert from English to Pig Latin, each word must be transformed as follows:

if the word begins with a vowel, way should be appended (example: apple becomes appleway)

if the word begins with a sequence of consonants, this sequence should be moved to the end, prefixed with a and followed by ay (example: please becomes easeaplay)

NB: Assume, when reverting Pig Latin to English that the original English text does not contain the letter "w".

The Python module will contain the following functions:

to_pig_latin(sentence)

Return the Pig Latin sentence for a given English sentence.

to_english(sentence)

Return the English sentence for a given Pig Latin sentence.

Sample I/O:

(E)nglish or (P)ig Latin?

E

Enter an English sentence:

the quick black fox jumps over the lazy apple

Pig-Latin:

eathay uickaqay ackablay oxafay umpsajay overway eathay azyalay

appleway

Sample I/O:

(E)nglish or (P)ig Latin?

P

Enter a Pig Latin sentence:

eathay uickaqay ackablay oxafay umpsajay overway eathay azyalay

appleway

English:

the quick black fox jumps over the lazy apple

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!