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
What is Hypertext Transfer Protocol?
densk [106]

Answer:

B

Explanation:

Web browsers use HTTP to send and receive information to and from the web.

3 0
4 years ago
Programmers refer to a sequence of characters as a ____.
jekas [21]
In programming they know it as a String which is  a sequence of characters that are composed of literal constants or some kind of variables. A sting is any finite sequence of characters. every single string has its own lenght and this is one of the most important characteristics of them. Strings are essential to communicate information from the program to the user. 
5 0
3 years ago
Need help plzz now it's hard ​
nalin [4]

Answer:

tost makinasıyla mı çektin amk bide siz zenginsizniz

Explanation:

5 0
3 years ago
PLZ sub to me on you tube at RESURGENTZ I would love to reach 100 subs by the end of this year have a great day. I GIVE BRAINLIE
oksano4ka [1.4K]

Answer:

I'll sub for ya!

Explanation:

Consider it done. I hope you reach your goal!

4 0
3 years ago
Read 2 more answers
Write a program in python that can compare the unit (perlb) cost of sugar sold in packages with different weights and prices. Th
Dmitrij [34]

Answer:

weight1 = float(input("Enter the weight of first package: "))

price1 = float(input("Enter the price of first package: "))

weight2 = float(input("Enter the weight of second package: "))

price2 = float(input("Enter the price of second package: "))

if weight1 > 0 and price1 > 0 and weight2 > 0 and price2 > 0:

   unit_cost1 = price1 / weight1

   unit_cost2 = price2 / weight2

   

   if unit_cost1 < unit_cost2:

       print("Package 1 has a better price.")

   else:

       print("Package 2 has a better price.")

else:

   print("All the entered values must be positive!")

Explanation:

*The code is in Python.

Ask the user to enter the weight and the price of the packages

Check if the all the values are greater than 0. If they are, calculate the unit price of the packages, divide the prices by weights. Then, compare the unit prices. The package with a smaller unit price has a better price.

If all the entered values are not greater than 0, print a warning message

8 0
3 years ago
Other questions:
  • The BIOS feature that enables a hard drive to read or write several sectors at a time is called what?
    5·1 answer
  • If I add a # symbol in front of the cells row/column, it will keep the value true.
    14·1 answer
  • which quotation from the story of the fisherman in the Arabian nights' entertainments supports the theme that cleverness trumps
    15·1 answer
  • Why is ice even more dangerous than snow
    9·2 answers
  • What is top down design? a. Top down design is a way of designing your program by starting with the biggest problem and breaking
    7·1 answer
  • For this program you will build a simple dice game called Pig. In this version of Pig, two players alternate turns. Players each
    6·1 answer
  • Tricia is managing tasks that have been assigned to her. She needs to enter mileage information in relation to a project. Which
    5·1 answer
  • Ingredient Adjuster
    11·1 answer
  • kidede secondary school in Kotido district has been selected to participate in the final continental debating competitions with
    9·2 answers
  • Evaluating sorts given the following array: 41, 32, 5, 8, 7, 50, 11 show what the array looks like after the first swap of a bub
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!