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
icon
Related questions
Question
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
Transcribed Image Text: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:
Transcribed Image Text: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:
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning