Write python code that takes word and converts to pig latin

Assignment Help Python Programming
Reference no: EM131395231

Problem 1(a): Pig Latin.

In "Pig Latin", English words are transformed according to the following rules:

If the word begins with one or more consonants, those consonants are moved to the end of the word, followed by "ay":

  • pig -> igpay
  • Latin -> Atinlay
  • trash -> ashtray

If the word begins with a vowel, it is followed by "yay":

  • apple -> appleyay
  • out -> outyay.

Note that more than one consonant may be moved to the end of the word. Note also that"y" functions as a consonant at the start of words. Note also that capitalization should be preserved after manipulating the word.

Write Python code that takes a word and converts it to Pig Latin. If the input consists of multiple words or contains punctuation, your code should print a suitable error message.

Problem 1(b): Test Suite.

Test your code on the following words, and be sure your output matches what is shown on the right hand side of each arrow. Print the results of each test. If your output does not match, then fix your code in 1(a).

* orange -> orangeyay

* yellow -> ellowyay

* Strip -> Ipstray

* quarter -> arterquay

* schmooze -> oozeschmay

* a -> ayay

* Pig Latin -> (should produce an error message)

* Ke$ha -> (should produce an error message)

Problem 2(a): Letter Frequencies.

The files encryptedA.txt and encryptedB.txt contain two different encrypted messages on similar topics. One message was originally in English and one was in Welsh.

Write Python code that reads a text file into memory and creates a dictionary object with a frequency count for each letter. For example, for encryptedA.txt, your output should contain the key:value pairs 'a': 78 and 'b': 31. Do not distinguish between uppercase and lowercase letters, and ignore punctuation. If a given letter does not appear in the text, there should be a key:value pair with value 0.

Use Python to determine which letter has the highest frequency in each text file, and print the result.

Problem 2(b): Formatting for R.

Write your dictionaries with frequency counts to .csv files, with one column for the key and one column for the frequency counted.

Reference no: EM131395231

Questions Cloud

Form of argumentation - circle : Determine whether the following arguments are inductive or deductive. If an argument is inductive, determine whether it is strong or weak. If it is deductive, determine whether it is valid or invalid.
Is there sufficient evidence of fraud : From a project management perspective, is there sufficient evidence of fraud? Why or why not? If you were Paul, what evidence would you bring to either support fraud or deny that fraud existed? How do you think the case study ended? Why?
Create the appropriate relationships between each entity : If you're using Visio, see "Appendix A: Designing Databases with Visio Professional 2010: A Tutorial" to help you complete Section 1: Modified Visio Database Design. For each student, the college needs to track the student  ID, student names, addre..
Determine whether it is strong or weak : Determine whether the following arguments are inductive or deductive. If an argument is inductive, determine whether it is strong or weak. If it is deductive, determine whether it is valid or invalid.
Write python code that takes word and converts to pig latin : Write Python code that takes a word and converts it to Pig Latin. If the input consists of multiple words or contains punctuation, your code should print a suitable error message
Statement is redundant or plays no role in the argument : Use the method presented in this section to construct argument patterns. If a statement is redundant or plays no role in the argument, do not include it in the pattern.
Government policy of managing the country : Briefly explain the "pros" and "cons" of a government policy of "managing"the country's foreign exchange rate as compared to a policy of letting the exchange rate "free float" according to prevailing market forces.
In which direction does the stack grow : In which direction does the stack grow: upward toward higher addresses or downward toward lower addresses? In an array on the free store, are elements with higher indices allocated at higher or lower addresses?
What will be the systems money supply : Assume a financial system has a monetary base (MB) of $25 million. The required reserves ratio is 10 percent and no leakeges are in the system. What is the size of the money multiplier (m)? What will be the systems money supply?

Reviews

len1395231

2/16/2017 12:51:29 AM

Write Python code that takes a word and converts it to Pig Latin. If the input consists of multiple words or contains punctuation, your code should print a suitable error message. Note that more than one consonant may be moved to the end of the word. Note also that"y" functions as a consonant at the start of words. Note also that capitalization should be preserved after manipulating the word.

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd