Question

. Write a function in python that accepts a sentence as the argument and converts each...

. Write a function in python that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY.

Homework Answers

Answer #1

def Pig_latin(sentence):
# to extract words from string
word = sentence.split()
new_sentance=""
  
for i in range(len(word)):
temp=word[i]
#swap word
a=temp[0] #first character of word
b=temp[1:]+a #place fisrt chracter to last
word_fin=b+"AY "
new_sentance=new_sentance+word_fin;
print(new_sentance)   
  
Pig_latin("I SLEPT MOST OF THE NIGHT")

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following: . The total sales for each week . The average daily sales for each week . The total sales for all of the weeks .The average weekly sales .The week number...
Write a program that translates a sentence into Pig Latin. Recall that this means that, for...
Write a program that translates a sentence into Pig Latin. Recall that this means that, for a given word: Develop this program in steps: 1 – prompt the user for a word 2 – using a while loop (NOTE: conditions should be that your index is less than the length of the word AND that the letter at the current index is a vowel) COUNT the number of consonants (i.e. non-vowels) at the start of the word. Note, for a...
Write a program that accepts an input string from the user and converts it into an...
Write a program that accepts an input string from the user and converts it into an array of words using an array of pointers. Each pointer in the array should point to the location of the first letter of each word. Implement this conversion in a function str_to_word which returns an integer reflecting the number of words in the original string. To help isolate each word in the sentence, convert the spaces to NULL characters. You can assume the input...
C++ Pig Latin Lab This assignment uses pointers to perform something done often in computer applications:...
C++ Pig Latin Lab This assignment uses pointers to perform something done often in computer applications: the parsing of text to find “words” (i.e., strings delineated by some delimiter). Write a program that encodes English language phrases into Pig Latin. Pig Latin is a form of coded language often used for amusement. Many variations exist in the methods used to form Pig Latin phrases. Use the following algorithm: to form a Pig Latin phrase from an English language phrase, tokenize...
In Python: Problem 5] Write a function that accepts a list as argument and returns a...
In Python: Problem 5] Write a function that accepts a list as argument and returns a list that contains: (1) The positive elements of the taken list (2) The negative elements of the taken list (3) The odd elements of the taken list (4) The even elements of the taken list
Write a function that takes as input an English sentence (a string) and prints the total...
Write a function that takes as input an English sentence (a string) and prints the total number of vowels and the total number of consonants in the sentence. The function returns nothing. Note that the sentence could have special characters such as dots, dashes, and so on. write a python program please.
Write a function that accepts a line of text and a single letter as input (case...
Write a function that accepts a line of text and a single letter as input (case insensitive) and returns the number of times the letter is the first character of a word. Note your program should be able to handle different cases. And check if the user input is a single letter. Example: Input text = "When the SUN rises at dawn, the chicken flies into the window." Input letter = "t" Output = "The letter t has appeared 3...
#Python Using a for loop, write a function called farmAnimals() that accepts a list of animals...
#Python Using a for loop, write a function called farmAnimals() that accepts a list of animals on a farm, identifies the typical farm animals, and returns a list of these typical farm animals on the farm without duplicates. For this function, your typical farm animals are cow, chicken, goat, pig, and sheep. Sample output; >>> animalsOnFarm = ['cow', 'cow', 'cow', 'dog', 'cat', 'bird'] >>> farmAnimals(animalsOnFarm) ['cow'] >>> animalsOnFarm = ['pig', 'sheep', 'cow', 'cow', 'cow', 'dog', 'cat', 'bird'] >>> farmAnimals(animalsOnFarm) ['pig',...
1.Create a function that will let you enter in a word or sentence in lower case...
1.Create a function that will let you enter in a word or sentence in lower case (as a user input) and will convert the input to a string with the first letter capitalized. Next, use the format method to print the following result: "Before: word, After: Word" i.e. >>> Enter a word: house >> Before: house, After: House 2. Write a program that will let you enter a sentence and will print each word out separately with the first letter...
IN PYTHON Stretch Remember that while it’s a good idea to have one person primarily responsible...
IN PYTHON Stretch Remember that while it’s a good idea to have one person primarily responsible for typing (the driver) and the other reviewing each line of code and making suggestions (the navigator) you must switch roles after every problem. 1). List Construction Write a Python program that prompts the user to enter a sequence of lowercase words and stores in a list only those words whose first letter occurs again elsewhere in the word (e.g., "baboon"). Continue entering words...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT