1 $ cat test.txt 2 Hello, how are you? 3 $ python3 piglatin.py 4 Enter English filename >>> test.txt 5 Enter filename to write to >>> test_piglatin.txt 6 Done. 7 $ cat test_piglatin.txt selloHay owhay areway ouyay Exercise 5.2 (piglatin.py). Write a program that translates a file from English to pig latin. The rules for pig latin are as follows: For a word that begins with consonants, the initial consonant or consonant cluster is moved to the end of the word and "ay" is added as a suffix: "happy" → "appyhay" "glove" → "overlay" For words that begin with vowels, you add "way" to the end of the word: "eggway" "inbox" "inboxway" For your program, you must write a function that takes in one individual word and returns the translation to pig latin. Write another function that takes a string, which may be sentences (may contain the characters "a-zA-Z.-;!?0" and space), and returns the translation of the sentence to pig latin. Strip out any punctuation. For example, "Hello, how are you?" would translate into "elloHay owhay areway ouyay". The user must be able to specify the filename for the file to be translated and the filename that the program should write to. For example:
1 $ cat test.txt 2 Hello, how are you? 3 $ python3 piglatin.py 4 Enter English filename >>> test.txt 5 Enter filename to write to >>> test_piglatin.txt 6 Done. 7 $ cat test_piglatin.txt selloHay owhay areway ouyay Exercise 5.2 (piglatin.py). Write a program that translates a file from English to pig latin. The rules for pig latin are as follows: For a word that begins with consonants, the initial consonant or consonant cluster is moved to the end of the word and "ay" is added as a suffix: "happy" → "appyhay" "glove" → "overlay" For words that begin with vowels, you add "way" to the end of the word: "eggway" "inbox" "inboxway" For your program, you must write a function that takes in one individual word and returns the translation to pig latin. Write another function that takes a string, which may be sentences (may contain the characters "a-zA-Z.-;!?0" and space), and returns the translation of the sentence to pig latin. Strip out any punctuation. For example, "Hello, how are you?" would translate into "elloHay owhay areway ouyay". The user must be able to specify the filename for the file to be translated and the filename that the program should write to. For example:
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning