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]
3 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]3 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
How did Matt Pyke and Karsten Schmidt create the advertisement for Audi? Multiple choice question. Filmed the car as wind tossed
saw5 [17]

Matt Pyke and Karsten Schmidt wrote a programming code that created the video which they used for the advertisement for Audi. Thus, Option D is the correct statement.

<h3>What is a programming code?</h3>

Programming code refers back to the set of instructions, or a system of rules, written in a specific programming language (i.e., the source code).

It is likewise the term used for the source code after it's been processed with the aid of using a compiler and made ready to run on the computer (i.e., the object code).

Therefore, Matt Pyke and Karsten Schmidt wrote a programming code that created the video which they used for the advertisement for Audi. Option D is the correct statement.

Learn more about programming code:

brainly.com/question/25770844

#SPJ1

8 0
1 year ago
If ADD = 81, BAD = 49, and CAD = 64, then what is the value of ACA?
Digiron [165]

Answer:

its 72

Explanation:

i know it because i did it and thats how i know it

6 0
2 years ago
Question: Convert data into another form.
Anna11 [10]

Answer:

Data transformation is the process of changing the format, structure, or values of data.

Explanation:

6 0
3 years ago
In a ______________ graphic you can include text and pictures and you can apply colors, effects, and styles that coordinate with
DerKrebs [107]
In a presentation graphic
8 0
2 years ago
What is the output of the following code? stackList stack; int x, y; x = 2; y = 3; stack.push(8); stack.push(x); stack.push(x +
Sunny_sXe [5.5K]

Stack is LIFO data structure (Last In First Out) where the last element entered in stack will be the last one to be out of stack. It has three operations: push() : used to insert an element in stack, pop() : used to delete an element from the stack, top() : used to return the top of the stack i.e. the newest member of the stack. All these operations will take place at the top.

<u>Explanation:</u>

Now, looking at the program, x and y are initialized the values of 2 and 3 respectively. The stack pushes 8 onto the stack making it the first member of the stack. Then the value of x which is 2 is pushed onto the stack. Next, (x+5) = (2+5) = 7 is pushed onto the stack.

Pop() is used to delete hence 7 is popped out from the stack. top() is assigned to y which is 2 in this case and again 2 is popped out from the stack. Now, (x+y) = (2+2) = 4 is pushed onto the stack. And the top() is assigned to x which is 4. 4 is again popped out from the stack. Hence the value of x is 4.

3 0
3 years ago
Other questions:
  • One is FPGA and other is ASIC. Budget, power consumption, and speed are the common parameters considered for the selection of th
    9·1 answer
  • A custom information field that helps users to find a specific document is called
    8·2 answers
  • Digital dashboards provide the decision makers with a quick overview of key performance indicators and other key operational sta
    13·1 answer
  • Assume that the population of Mexico is 114 million and that the population increases 1.01 percent annually. Assume that the pop
    9·1 answer
  • Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
    5·1 answer
  • In the ADT graph the methid addVertex has efficiency
    15·1 answer
  • The keyboard usually has six rows of keys. Which of the following is not one of the key group categories?
    7·2 answers
  • Write a function, named "wait_die_scheduler" that takes a list of actions, and returns a list of actions according to the follow
    11·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    9·1 answer
  • What are the two main parts to a VR experience.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!