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
What are the two options for adding a new slide into presentations?
nirvana33 [79]
The first being Ctrl+M and the second being clicking the <span>top half of the New Slide button</span>
5 0
3 years ago
(20 points) Given a collection of n nuts and a collection of n bolts, arranged in an increasing order of size, give an O(n) time
Blababa [14]

Answer:

Check the explanation

Explanation:

Keep two iterators, i (for nuts array) and j (for bolts array).

while(i < n and j < n) {

if nuts[i] == bolts[j] {

We have a case where sizes match, output/return

}

else if nuts[i] < bolts[j] {

what this means is that the size of nut is lesser than that of bolt and we should go to the next bigger nut, i.e., i+=1

}

else {

what this means is that the size of bolt is lesser than that of nut and we should go to the next bigger bolt, i.e., j+=1

}

}

Since we go to each index in both the array only once, the algorithm take O(n) time.

6 0
3 years ago
What is spam? a type of virus that spreads from computer to computer through a network connection a type of virus that targets p
Bas_tet [7]

Answer:

This is a pretty obvious answer.

An unwanted e-mail sent in bulk from people or organizations.

Explanation:

8 0
2 years ago
Does anyone know how to fix this error of " the media could not be loaded, either because the server or network failed or becaus
enyata [817]

Answer:

Restart your WiFi!

Explanation:

It happened to me I did that and it fixed it

7 0
3 years ago
Read 2 more answers
Which of the following is not a component of the programming phase of facility construction? deciding what to build examining sp
Anika [276]

Answer: designing the facility with architects.

Explanation: The programming phase of a facility construction has nothing to do with the architectural design of the facility. The programming phase usually involves ; Determining the needs of intended or impending users, estimated construction cost, required area for the project. The programming phase may involve individual or joint questioning or fact finding from the intended occupants or user group to determine their needs in terms of systems and infrastructure, security and so on. It also gets intended occupants informed on the features, use and design of the intended project. It also examines the effect of the project on structures previously existing in the environment.

4 0
3 years ago
Other questions:
  • Deterime the minimum number of multiplication operations needed to compute the following. Show the order of the computations.
    10·1 answer
  • A(n) ________ is usually a live broadcast of audio or video content. Select one: A. instant message B. webcast C. podcast D. wik
    11·2 answers
  • What is the digital revolution and how did it change society? What are the benefits of digital media?
    8·1 answer
  • You are the network administrator for a company with a single Active Directory domain. The corporate office is located in Miami
    5·1 answer
  • A ______ is a computer that controls access to the hardware, software, and other resources on a network. mainframe server workst
    10·1 answer
  • How does a hard drive work
    6·1 answer
  • The radix sort
    7·1 answer
  • Please help I upped the points and please don't answer if you don't have the answer..
    13·1 answer
  • Where can formatting features be found ?! Need help asp !‍♀️
    9·1 answer
  • A smartphone user notices that their phone gets very hot, and their battery is draining quickly. Even when the phone is in their
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!