Question: I need to write a python code. These are the instructions: Write a module, latin.py, with two functions wordToPig and nameToPig. Your wordToPig function

I need to write a python code. These are the instructions:

" Write a module, latin.py, with two functions wordToPig and nameToPig. Your wordToPig function will take 1 parameter that converts the word based on the below rules. Your nameToPig function takes 2 input parameters, firstName and lastName, and will use your wordToPig function to do the translation to avoid duplicating code. Your nameToPig function returns the names in pig Latin. Test your functions with input from the user, you only need test a name, not a word and then a name. Please use the following guidelines for Pig Latin:

Words beginning with consonants: move the consonant from the start of the word to the end of the word. Then add the suffix "ay" to the end of the word. For example, the word "hello" would become ellohay, the word "duck" would become uckday.

o For a bonus, remove all consonants from the start of the word to the end of the word and then add the suffix ay to the end. For example, Chapman becomes Apmanchay.

Words beginning with vowels: all you need to do is add "yay" to the end of the word. You don't need to change any letters around, just say the word as normal then add "yay" to the end. For example: the word "egg" becomes eggyay and the word "ultimate" becomes ultimateyay.

Make sure to use your string methods so you have capital letters where appropriate and not otherwise. Test your functions with input from the user. Assume the user enters his/her name with capitals for both their first and last name."

This is what I have so far for the wordToPig function:

def wordToPig(word): first_letter = word[0] #if the word starts with a vowel if first_letter == ('a' or 'e' or 'i' or 'o' or 'u'): pig_latin_word = word + 'yay' return pig_latin_word #if the word starts with a consonant else: pig_latin_word = word[1::] + first_letter + 'ay' return pig_latin_word

word = str(input("Enter a word to convert it to pig latin: "))

print("The word in pig latin is",wordToPig(word),".")

It converts correctly for words that start with consonants, but it converts words that start with vowels the same way. For example, egg becomes ggeay but it should be eggyay. And then, obviously, I haven't started on the second function for names.

Any help would be appreciated!!

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!