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

  Design an application in python

Design an application in Python- The application would generate a set of 100 integers in a random manner in the range of 50 to 150 including both the numbers in the range

  Design reusable parameterised functions

create multiple icon styles that can be drawn at different sizes, it would be very repetitive if you tried to code the whole solution using ‘brute force.' Instead you are strongly encouraged to design reusable parameterised functions to draw the i..

  Determine how many students scored above the average

He wants to average the grades for his last exam in his medieval literature course and then determine how many students scored above the average and how many scored below.

  Tower of hanoi game

Tower of Hanoi game that you can let a player to move discs between the towers using a mouse - Each move consists of taking the upper disk from one of the pegs and sliding it onto another rod, on top of the other disks that may already be present o..

  How does the given change your programming capabilities

CS 192- Considering the lessons on menu logic and the use of arrays and loops, how does this change your programming capabilities? What kind of programs can you now create utilizing these powerful programming tools?

  Design and implement mini-missions in the haunted house

Create a cheat commands in the game so player can pick up any item he wants from any location in the map. You have to name this cheat command 'giveme'

  In this assignment you will write a program that does

in this assignment you will write a program that does simple packet routing. your program will take three command-line

  How when you are typing a text message

You have all experienced how when you are typing a text message the application will provide potential words that complete what you are typing (and sometimes insist on completing them incorrectly).

  The initial number for generating the sequences

Then, after the functions, read in the initial number for generating the sequences. Here, check that it is a positive integer. If it is not, give an error message and exit the program.

  Write program that read a text file and prints only odd line

Write a program that reads a text file and prints out only odd lines to the screen. Thus, lines 1, 3, 5,... only printed. Update your odd lines program (Q1) to write odd lines to the screen and write then lines to another file.

  Create a ride share simulator assignment

Create a ride share simulator assignment. In this particular function, I am trying to create a list of the drivers in a Driver Class that are currently listed as idle. Since they are idle, I can then match them up with an awaiting rider. The assignme..

  Prepare program that will compute tip and tax on meal price

CS21A Lab 3: Functions- Write a program that will calculate a XXX% tip and a 6% tax on a meal price. Python comes with a standard library of functions. Some of the functions that you have used already are input, type, and range.

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