Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM 2: WRITING A PIG LATIN CONVERTER (a) Write a function pig-latin that takes in a single word, then converts the word to Pig Latin.

image text in transcribed

PROBLEM 2: WRITING A PIG LATIN CONVERTER (a) Write a function pig-latin that takes in a single word, then converts the word to Pig Latin. To review, Pig Latin takes the first letter of a word, puts it at the end, and appends ay". An exception is if the first letter is a vowel, in which case we keep it as it is append "hay" to the end. Another exception is that for words that start with "th", >" st" "qu", "pl", or "tr", you should move both of those letters to the end. For example: For the input parameter "boot", return "ootbay" For the input parameter is "image", return "imagehay". For the input parameter "stop", return opstay" For the input parameter "there", return "erethay" and (b) Converting one word to Pig Latin is okay, but it would be more useful to be able to convert whole sentences; so for this part, use rawinput to ask the user for a full sentence and translate it, word by word. The pig latin converter should only return lowercase words. To avoid dealing with punctuation and numbers, ask the user to enter only words and spaces. If the user enters a sentence with punctuation or numbers, print an appropriate message to them. You can convert their input from a string to a list of strings by calling the split method on the entered string. You can also use the method lower to make the string all lowercase. See below for examples on how to use the split and lower mcthods: >>> phrase My namE is JohN SmIth >>> word-list = phrase, split() >> print word_list CMy, namE, is, JohN, SmIth] >>> lower case-phrase = phrase.lower() >>> print lowercase_phrase my name is john smith Finally, your program must be interactive: it keeps translating phrases into pig latin until the user enters the phrase QUIT

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions