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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started