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
Identify the names of the following:<br><br>Please help me.​
patriot [66]

Hi,

1st photo is <u>Printer</u>

2nd photo is <u>Hard </u><u>Disk</u>

3rd photo is <u>Printer's </u><u>internal </u><u>CPU</u>

<em>Hope</em><em> it</em><em> helps</em><em> you</em><em>.</em><em>.</em><em>.</em><em> </em><em>pls</em><em> mark</em><em> brainliest</em><em> if</em><em> it</em><em> </em><em>helps</em><em> you</em>

5 0
3 years ago
Which of the following statements is true for DMA: (only one correct answer) A. In DMA, Processor checks status until the operat
Ronch [10]

Answer:

<u>D. In DMA, interrupt is sent when the task is completed</u>

Explanation:

Note, the term Direct Memory Access simply refers to a computer feature that allows hardware subsystems to directly access the main system memory of a computer, without any the aid of the central processing unit (CPU).

It is a fact that while the transfer process is ongoing, an interrupt (interrupt signal) is not sent until when the task is completed.

6 0
3 years ago
(Just wondering and for fun) What can humanity do to survive after the universe dies? Assuming we have advanced tech and there a
Troyanec [42]

Answer:

If this is for fun. then may I take points for free. If not, then I will post my answer :)

Explanation:

5 0
3 years ago
Try to crack the code:
ololo11 [35]

Answer:001101110010010100011011010110010011100100100000001100100100110001000010001101100100010100100000001101100100100001010001010101001101001010

Explanation:

i copied

3 0
2 years ago
NumA=2<br> for count range (5,8)<br> numA=numA+count <br> print(numA)
love history [14]

Answer:

for count in range (5,8): numA=numA+count print(numA)

Explanation:

7 0
3 years ago
Other questions:
  • HELP ME RIGHT NOW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8·1 answer
  • Ruby is creating a presentation. She wants each slide displayed at intervals of five seconds. Which feature in the presentation
    6·2 answers
  • In this question, you must create a function in C++ using an external editor. When satisfied with your work, you shall attach it
    10·1 answer
  • Write a program to calculate the great circle distance between two points on the surface of a sphere. If p1(x1, y1) and p2(x2,y2
    5·1 answer
  • What are the text or graphics that are lighter than the main text located in a document's background called?
    10·1 answer
  • What function returns a line and moves the file pointer to the next line?
    9·1 answer
  • A prefab allows you to reuse game objects over and over, while their component data remains intact. (1 point)
    14·1 answer
  • What is the data type of the following expression?
    12·2 answers
  • Can you help me with this question please ​
    13·1 answer
  • if we intend to include a servo motor as an actuator, what feature should we include when selecting a microcontroller?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!