1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sliva [168]
4 years ago
8

Write a function getPigLatin(pigStr) that accepts pigStr as a parameter (a sentence as input) and converts each word to "Pig Lat

in." and returns the entire string in Pig Latin. In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then, you append the string "ay" to the word. Here is an example:
English: I SLEPT MOST OF THE NIGHT


Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY
Computers and Technology
1 answer:
Vladimir79 [104]4 years ago
8 0

Answer:

userInput = str(input("Enter your sentence here.\n")).upper()

def getPigLatin(userInput):

   splitInput = userInput.split(" ")

   newList = []

   for word in splitInput:

       firstLetter = word[0]

       if len(word) == 1:

           word += 'AY'

           newList.append(word)

       else:

           word = word.strip(word[0])

           word += firstLetter

           word += 'AY'

           newList.append(word)

   print(*newList, sep= " ")

getPigLatin(userInput)

Explanation:

This solution is done in Python

First the user is prompt to enter a statement, the statement converted to string and also capitalize using str and upper() built-in function. The user input is assigned to userInput variable.

The getPigLatin function is defined and it accept a string as parameter. Inside the getPigLatin function, the userInput is splitted and assigned to splitInput variable.

An empty list is also initialized and assigned to newList. Next, we loop through the splitInput. During the loop; we first check if the length of an element is one, then we just add 'AY' to the element and add the element to the newList. Else, if the element length is more than one; we strip the first letter from the word and also re-assign it to word, then the stripped first letter is added to the end of the word. Next, 'AY' is added to the word and the element is add to the newList.

The last line of the getPigLatin function display the entire element of the list using a space seperator.

The last line of the entire solution call the function passing in the userInput as argument.

You might be interested in
On a timeline, a milestone 11 years in the future will be to the
aniked [119]

Answer:

D. Left,left

11 is less than 20 as well as it is less than 25 years. And we move from left to right on the timeline. Thus 11 is left of 20 and it is left of 25 years as well. And timeline is the core of a project management software. The Gantt and Pert chart are totally based on the timeline. Software like Microsoft project use the timeline quite a lot, and you cannot survive without the knowledge  of the timeline in software project management.

Explanation:

Timeline knowledge is a must for a software professional, and the above answer does not require explanation.

6 0
4 years ago
2. When was the Antikythera mechanism discovered? What year? <br>​
Vlad [161]

Answer: 1901

Explanation:

7 0
3 years ago
Read 2 more answers
In computer terminology, what is a network?
RSB [31]
It is like where two or more computers are connected and they exchange informations, (sharing) and also they can communicate. and also share their some softwares etc. etc... This is called network in computer terminology

4 0
3 years ago
Describe any five Morden application areas of computer​
Alecsey [184]

Answer:

Some of the application areas of computer are 

1.banking,

2.education,

3.industries,

4.entertainments,

5.hospitals,

7 0
3 years ago
Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter. Ex: sortArray = {10,
ludmilkaskok [199]

Answer:

Replace /* Your solution goes here*/ with the following

<em>void SwapArrayEnds(int sortArray [], int lent){ </em>

<em>    int temp = sortArray[0]; </em>

<em>    sortArray[0] = sortArray[lent-1]; </em>

<em>    sortArray[lent-1] = temp; </em>

<em>} </em>

<em />

Explanation:

This defines the function SwapArrayEnds with two parameter (the array and the array length)

<em>void SwapArrayEnds(int sortArray [], int lent){ </em>

This declares an integer variable "temp" and initializes it with the first element of the array

<em>    int temp = sortArray[0]; </em>

The next two lines swap the last element with the first

<em>    sortArray[0] = sortArray[lent-1]; </em>

<em>    sortArray[lent-1] = temp; </em>

<em>} </em>

<em />

<em>See attachment for full program</em>

Download cpp
3 0
3 years ago
Other questions:
  • Bar-code readers are typically used to track large numbers of inventory items, as in grocery store inventory and checkout, packa
    14·1 answer
  • has anyone noticed that brainly has been giving the wrong answers and that the ads are blocking answers or is that just me?
    7·2 answers
  • What the repeal of online privacy protections means for you?
    8·1 answer
  • What kind of programming language allows you to use a vocabulary of reasonable terms such as "read," "write," or "add" instead o
    13·1 answer
  • Many inventions have enabled us to use digital cameras. The biggest difference between traditional and digital cameras is that d
    10·1 answer
  • Kenny needs to keep client information such as names and addresses. She should use a
    7·2 answers
  • If you have 128 oranges all the same size, color, and weight except one orange is heavier than the rest. Write down a C++ Code/A
    7·1 answer
  • Can we update App Store in any apple device. (because my device is kinda old and if want to download the recent apps it aint sho
    10·1 answer
  • Which type of database program is Microsoft Access 2016?
    7·2 answers
  • Write a C console application that will be used to determine if rectangular packages can fit inside one of a set of spheres. You
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!