Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So im creating a pig latin translator but im having problems with my code for splitting the word #!/usr/bin/env python3 def is_vowel(letter): return letter.upper() in

image text in transcribedimage text in transcribedSo im creating a pig latin translator but im having problems with my code for splitting the word

#!/usr/bin/env python3

def is_vowel(letter): return letter.upper() in 'AEIOU'

def has_vowel(word): if word.find('AEIOU'): return word[1:] + word[0] + 'ay'

def has_vowel_maybe(word): for letter in word: if is_vowel(letter) is True: return word + 'way' elif word.find('AEIOU'): return word[1:] + word[0] + 'ay' #return False def translate(word): if is_vowel(word[0]): return word + 'way' elif has_vowel_maybe(word): return has_vowel_maybe(word) elif has_vowel(word): return has_vowel(word) else: return word + 'way'

print('This program will translate a word from English to Pig Latin.') choice = 'y'

while choice.upper() == 'Y': word = input('Please enter a word: ') print(word, 'becomes' , translate(word) + '.') choice = input('Would you like another word? (Y/N) ')

print('Ankthay ouyay!')

COSC 1306 Assignment #5 Objective: Practice using strings with loops, functions, and conditional execution. Description: In this assignment you will ask the user to input an English word, translate that word into "Pig Latin" and then print both words Your program must meet the following requirements 1. Include a multi-line comments at the top of the file with your name, PSID number, and the assignment number 2. Your program should ask the user for a word in English 3. Your program should use a function to translate that word into "Pig Latin" and returns the translated word. You should then print both words. See below for the translation rules 4. Your program should prompt the user to repeat or exit the program 5. For the same input you program should match the output shown below Hint: Implement the translation one step at a time and test each step Deadline: Saturday, October 20, 2018, 11:59PM Example Output: The following is one possible run with example sets of inputs This program will translate a word from English to Pig Latin Please enter a word: Cat Cat becomes Atcay. Would you like another word? (Y/N) y Please enter a word: by by becomes byway. Would you like another word? (Y/N) Y Please enter a word: Away Away becomes Awayway. Would you like another word? (Y/N) Y Please enter a word: tree tree becomes eetray. Would you like another word? (Y/N) n Ankthay ouyay! COSC 1306 Assignment #5 Objective: Practice using strings with loops, functions, and conditional execution. Description: In this assignment you will ask the user to input an English word, translate that word into "Pig Latin" and then print both words Your program must meet the following requirements 1. Include a multi-line comments at the top of the file with your name, PSID number, and the assignment number 2. Your program should ask the user for a word in English 3. Your program should use a function to translate that word into "Pig Latin" and returns the translated word. You should then print both words. See below for the translation rules 4. Your program should prompt the user to repeat or exit the program 5. For the same input you program should match the output shown below Hint: Implement the translation one step at a time and test each step Deadline: Saturday, October 20, 2018, 11:59PM Example Output: The following is one possible run with example sets of inputs This program will translate a word from English to Pig Latin Please enter a word: Cat Cat becomes Atcay. Would you like another word? (Y/N) y Please enter a word: by by becomes byway. Would you like another word? (Y/N) Y Please enter a word: Away Away becomes Awayway. Would you like another word? (Y/N) Y Please enter a word: tree tree becomes eetray. Would you like another word? (Y/N) n Ankthay ouyay

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

1. Identify six different types of history.

Answered: 1 week ago