Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program is written in Python Pig Latin is a form of coded English often use

ID: 3666300 • Letter: T

Question

This program is written in Python

Pig Latin is a form of coded English often used for amusement. There are many variations on the method used to form pig Latin sentences. Here, we use the following simple algorithm to translate an English word into pig Latin:

If the English word begins with a consonant, place the initial cluster of consonant letters at the end of the word, followed by the letters “ay” to it. For example, “road” translates to “oadray”, “scream” translates to “eamscray”, and “fly” translates to “flyay”.

If the English word begins with a vowel (a vowel is one of ’a’,’e’,’i’,’o’, or ’u’), simply add the letters “way” at the end of the word. For example, “apple” translates to “appleway” and “I” translates to “Iway”.

Write a program that translates English language sentences into pig Latin. We will assume that the sentence is made up of words separated by blanks. A word is a string of letters without blanks and may end in a punctuation mark, which we assume to be one of . (period) ! (exclamation) ? (question mark) or , (comma). We assume there are no other punctuation marks in the sentence. The punctuation marks and blanks stay as they are in the pig Latin translation. Implement the following functions in your program.

Write a function called pig_latin word with a single parameter word. Assume that word is a string of characters without any spaces or punctuation marks in it. The function returns a string that is the pig Latin translation of word.

Write a function called pig_latin_sentence with a single parameter eng_sentence, which is an English language sentence. The function returns a string which is the pig Latin translation of eng_sentence. Hint: Construct the pig Latin translation by breaking up eng sentence into words, each of which can be translated using pig_latin_word. Make sure you handle punctuation marks properly.

Write a function called pig_latin_translator without any parameters. The function repeatedly reads in an English sentence from the user and then uses the function pig_latin_sentence to print out the pig Latin translation of that sentence.

Here is a sample run:

------------------------------- English to Pig Latin Translator -------------------------------

Enter the English sentence: Look! His tie is ugly.

In Pig Latin: ookLay! isHay ietay isway uglyway.

Do another? [y/n] y

Enter the English sentence: Are you speaking Pig Latin?

In Pig Latin: Areway ouyay eakingspay igPay atinLay?

Do another? [y/n] n

Goodbye!

Please use correct indentation and make sure the program works.

Explanation / Answer

Multiple Questions : Answering 1st part

pig_latin word



def pig_latin_word(word) :
vowel = {'a','e','i','o','u','A','E','I','O','U'}
pun = {'?','!','.'}
if word[0] in vowel :
new_word =""
if word[len(word)-1] not in pun :
new_word = word + 'way'
return new_word
else :
for i in range(len(word)-1) :
new_word = new_word + word[i]
new_word = new_word + "Way"
new_word = new_word + word[i+1]
return new_word
temp1 = ""
temp2 = ""
temp3 = "ay"
for i in range(len(word)-1):
if word[i] not in vowel :
temp1 = temp1 + word[i]
else :
for j in range(i,len(word)-1):
temp2 = temp2 + word[j]
break
if word[len(word)-1] not in pun :
temp2 = temp2 + word[len(word)-1]
else :
temp3 = temp3 + word[len(word)-1]
temp2 = temp2 + temp1
temp2 = temp2 + temp3
return temp2
  
  
print(pig_latin_word("Look!"))

Output : ookLay!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote