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
![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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F645f5f13-b198-4aa8-9dad-4f403fda1bca%2F1c38c11b-237a-4da6-939c-d8969bd0bff5%2Fzgi27t_processed.png&w=3840&q=75)
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:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F645f5f13-b198-4aa8-9dad-4f403fda1bca%2F1c38c11b-237a-4da6-939c-d8969bd0bff5%2Fr9snp9p_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
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
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT