Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92491346
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Identify and evaluate at least three considerations that

Identify and evaluate at least three considerations that one must plan for when designing a database. Suggest at least two types of databases that would be useful for small businesses, two types for regional level organi ...

C programmingneed help with a c program arrayrearrangec

***C PROGRAMMING*** Need help with a C program array_rearrange.c that rearranges an integer array. The array will be split into two sets of integers one by one. A new array will be created by append the first set to the ...

Tetrafluoromethane cf4 is a greenhouse gas synthesized by a

Tetrafluoromethane (CF 4 ) is a greenhouse gas synthesized by a violently explosive reaction between methane and fluorine. In joules, what is the average kinetic energy of a molecule of CF 4  at 57.2°C and 0.0010 atm?

Do the next application and answer the questions1 print a

Do the next application and answer the questions: 1 /** Print a friendly greeting. */ 2 public static void main(String[] args) { 3 int index; 4 for(index = 0; index 6} 7} Questions: 1. What is the scope of index in the a ...

Small java programcreate an int called num and initialize

Small Java Program: Create an int called num and initialize it to 5000. Create an int called reps and initialize it to 0. Use a for loop control structure that runs if num is greater than or equal to 250, subtracting 139 ...

Question suppose you are given a turing machine m not

Question : Suppose you are given a Turing machine M (not necessarily a decider), a string w, and a (different) magic genie. You can ask the magic genie whether a certain Turing machine accepts a certain input string, and ...

Question define a class named taxreturn that contains a tax

Question : Define a class named TaxReturn that contains a tax ID number, last name, first name, annual income, number of dependents, and amount of tax owed for a taxpayer. Include constant static fields that

Question 1 what is rdbms2 what is key-value pair

Question: 1. What is RDBMS? 2. What is Key-Value Pair Databases? 3. What are the foundational behaviors of MapReduce? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Given the following table keynbspand fds repair

Given the following table, key and FDs, REPAIR (RepairInvoiceNumber, RepairDate, RepairCost, RepairEmployeeName, RepairEmployeePhone, SerialNumber, Type, TankCapacity) Candidate Keys: RepairInvoiceNumber, and (RepairDate ...

Take the case in which all individuals are risk averse so

Take the case in which all individuals are risk averse, so that marginal costs slope down. In that case, why might it be optimal (socially efficient) for insurance take up to be less than 100%?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As