IN PYTHON
Ask the user for a file name
Open the requested file
Split the contents of the file into words
Iterate over each word
Translate the word to Pig Latin
Output the translated word to the screen
How to Speak Pig Latin
https://www.wikihow.com/Speak-Pig-Latin
Source Code in Python:
def piglatin(s): #function to translate a string to
piglatin
vowel="aeiouAEIOU"
count=0 #variable to keep track of the initial consonants
for i in s:
if i in vowel: #if i is the first vowel
return s[count:]+s[0:count]+"ay"
else:
count=count+1
def main(): #main function
fileName=input("Enter filename : ") #taking filename as input
file=open(fileName,"r") #opening file in read mode
line=file.readline() #reading line from file
while line!="":
line=line.split() #splitting the line into a list of words
for i in line: #iterating through each word and converting it to
piglatin
print(piglatin(i),end=" ")
print()
line=file.readline() #reading next line
file.close() #closing file
main()

Text File:

Output:

IN PYTHON Ask the user for a file name Open the requested file Split the contents...
Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin.” The rules used by Pig Latin are as follows: • If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay". • If it begins with a consonant, then we take all consonants before...
Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin.” The rules used by Pig Latin are as follows: • If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay". • If it begins with a consonant, then we take all consonants before...
Python Programming Write a program that counts how often a word occurs in a text file. Input: Ask the user for the name of an ASCII text file. Output: Display the numbers of top frequently appeared words and their frequencies. Pseudocode: 1) Read the file 2) Split the file into words 3) Count each word 4) Sort the words by frequencies, starting with the most frequent ones 5) Internally you should use some sort of data structure to keep track...
Python Error: Writing a program to complete the following: Prompt the user for the name of an input file. Open that file for input. (reading) Read the file using a "for line in a file" loop For each line, o print the line and compute and print the average word length for that line. Close the input file Sample output: MY CODE IS WRONG AND NEED HELP CORRECTING IT!!! ------------------------------------------------------------------------------------------------------------------------ DESIRED OUTPUT: Enter input file name: Seasons.txt Thirty days hath September...
C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...
Write a complete Python program with prompts for the user for the main text file (checks that it exists, and if not, output an error message and stop), for any possible flags (including none), and for any other input that this program may need from the user: split has an option of naming the smaller files head_tail list the first 10 lines (default) and the last 10 lines (default) in order of the given text file flag: -# output #...
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
Write robust python code that take from the user the name of file to open. Then, take name from the user to search inside the file then display its phone number if found
In python your goal is to ask the user for Nouns, Verbs, Adjectives… and fit them in the text where they appear. Each word should be unique. e.g. ask the user for a Noun and replace the first appearance of [Noun] in the text below by the user input. Technical requirements: Save the following text to a file. Open the file and replace all the words in between [] by user inputs using .format(). (You can manually modify...
write a python program that prompts the user for a name of a text file, opens that file for reading , and tracks the unique words in a file and counts how many times they occur in the file. Your program should output the unique words and how often they occur in alphabetical order. Negative testing for a file that does not exist and an empty file should be implemented.