Question: In Python please (50 total for parts a and b) Write a function that translates English language text to Pig Latin according to the following

In Python pleaseIn Python please (50 total for parts a and b) Write a

(50 total for parts a and b) Write a function that translates English language text to "Pig Latin" according to the following rules for translating one word: If the word begins with a vowel (a, e, i, o, u), then it is simply translated by appending 'way' to the end of it. As examples, 'act' becomes 'actway' and 'old' becomes 'oldway' and so on. If the word does not begin with a vowel (it starts with a consonant), then it is translated by moving all consonant letters up to the first vowel to the end of the word with 'ay' appended to the very end. As examples, 'gasp' becomes 'aspgay' and 'school becomes 'oolschay' and so on. This rule also applies when the word has no vowels at all - in that case, 'ay' is simply appended. Special cases: The letter 'y' is counted as a vowel in this context (when a word begins with a consonant). Examples: 'system' becomes 'ystemsay' and 'crystal' becomes 'ystalcray' and so on. The letter 'u' is counted as a consonant when it follows the letter 'q' in a word, so 'queen' becomes 'eenquay' and 'square' becomes 'aresquay' for examples. Capitalization is properly maintained. Words that are all capital letters are translated to all capital letters ('IBM' becomes 'IBMWAY' and 'CRUMB' becomes 'UMBCRAY'). Also, words that are properly capitalized are translated with proper capitalization ('Apple' becomes 'Appleway' and 'Mark' becomes 'Arkmay') We suggest you solve this problem in two parts, and the points will be allocated accordingly. a. Get the function working for just one word. That is, full credit for this part is earned by translating text that consists of nothing except alphabetic characters. Return (don't print) the translated text as a string. See (and be sure to match) the first few sample runs below. b. Improve the function so that it works with text that consists of any characters, and presumably multiple words. Translate each word separately. A word is defined as any consecutive sequence of alphabetic letters, and they may be separated by any sequence of non-letter characters All non-letter characters should just be copied to the Pig Latin translation. The function header must exactly match the following: def pig Latin (text): Here are some sample runs of our pigLatin solution: >>> from project2 import pigLatin >>> pigLatin ('banana') 'ananabay' >>> p = pig Latin ("Apple") print (p) 'Appleway' >>> pigLatin ('Square') 'Aresquay' >>> pigLatin ('My hovercraft is full of eels.') 'Ymay overcrafthay isway ullfay ofway eelsway.' >>> pig Latin ('FDA says: "Three squares is the way to go!"') 'AFDAY ayssay" "Eethray aressquay isway ethay ayway otay ogay

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!