For intro to python class

Assignment Help Basic Computer Science
Reference no: EM131682647

For Intro to Python Class.

Pig Latin is a language game in which words are altered according to certain rules. 

To make the pig latin form of an English word, the initial consonant sound is transposed to the end of the word, and an "ay" is affixed. Specifically, there are two rules: 

  • If a word begins with a vowel, append "yay" to the end of the word. 
  • If a word begins with a consonant, remove all the consonants from the beginning up to the first vowel and append them to the end of the word. Finally, append "ay" to the end of the word. The letter "y" counts as a consonant. If there are no vowels, simply append "ay" to the end of the word. 

For example: 

  • dog => ogday
  • python => onpythay
  • scratch => atchscray
  • is => isyay
  • apple => appleyay

(a) In the file problem1.py, write a function

def piggify(word):...

that takes an input String word as its parameter and returns a string containing the pig latin translation of the word. You can assume that the input is always a lower-case string (no input verification is necessary). 

Hints: Use indexing and slicing. You might also want to use a string of vowels and then use the in operator to check if a letter is a vowel.

vowels = 'aeiou'

(b) In the same file, write a program that repeatedly prompts the user to input a new word and then prints the pig latin translation of the word (by calling the piggify function). When the user types a single period, the program should quit.

Reference no: EM131682647

Questions Cloud

Geometric arrangement of sums : Pascal's triangle is a geometric arrangement of sums that have interesting mathematical properties -- most famously, the binomial coefficients.
Discuss an evaporative cooling system : An evaporative cooling system is necessary for power plants in water short areas
How can health care delivery systems work collaboratively : Briefly describe the global health issue and its impact on the larger health care system (i.e., continents, regions, countries, states, and health departments).
Discuss indoor ozone concentration with time : Write a mass balance for the rate of change of indoor ozone concentration with time
For intro to python class : Pig Latin is a language game in which words are altered according to certain rules.
Explain the development of community programs : Measurement error is the difference between what exists in reality and what is measured by a research instrument.
What are the possible sources of exposure : What are the possible sources of exposure, What happens when it enters the environment
Controversy of personal information collection : It's about profession ethics. What are some unique challenges to resolving controversy of personal information collection when viewed on a global scale
Possibility of truncation errors : Is it acceptable for an individual to ignore the possibility of truncation errors and their consequences when developing his or her own application?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Calculate the stagnation pressure required at no loss

A fire hose nozzle is designed to deliver water that will rise 30 m vertically.

  Stack object data structures do not contain code

Stack object data structures do not contain code to throw an exception when a stack.pop() function is called on an empty stack. This is due to the fact that it is easy to establish this exception handing elsewhere. Create a class named SafeStack that..

  Program you must expose the data member

To expose a data member to a program you must expose the data member to which section of the class?

  Importance of employee security awareness training

Discuss the importance of employee security awareness training. What innovative ways should company's implement security training? Please provide examples to support your answer.

  Total cost of producing t-shirts

Suppose the total cost of producing T-shirts can be represented as TC = 50 + 2q. Which of the following statements is TRUE at all levels of production?

  Assume an open addressing hash table

Assume an open addressing hash table, with a load balance α given. What is the expected number of probs needed when searching a key x that is in the table. Note that the development shown in class was for the case that x is not in the table.

  Explain d-s access control list gives p full rights

Suppose that d's access control list gives p full (read, write, append, and execute) rights to d. In which ring(s) should p execute for following to occur?

  Problem regarding the it policy and strategy

Please read the following chapters that describe how information can be used strategically, which is the topic for this week's paper:

  Evaluates the product by adding the multiplicand four times

Let the multiplicand be in register RR, the multiplier in register AR. and the product in register PR. An adder circuit adds the contents of BR to PR. A zero-detection circuit Z checks when AR becomes 0 after each time that it is decremented.

  Are there sizes of triangle strip lengths that work better

Are there sizes of triangle strip lengths that work better than others? Try to determine the maximum size of a triangle strip that maximizes performance. What does this tell you about the memory, or cache structure, on the graphics hardware?

  Civil court trial processes

From the e-Activity, describe some of the processes that take place in a civil court trial.  Justify the length of time each process takes.

  Disadvantage of the corporate form of business

What APR is being earned on a deposit of $5000 made 10 years ago today if the deposit is worth $9848.21 today? The deposit pays interest semiannually. Which one of these is a disadvantage of the corporate form of business?

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