Your code needs to do the following: 1. Create a function called pigLatin that accepts a string of English words in the

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Your code needs to do the following: 1. Create a function called pigLatin that accepts a string of English words in the

Post by answerhappygod »

Your Code Needs To Do The Following 1 Create A Function Called Piglatin That Accepts A String Of English Words In The 1
Your Code Needs To Do The Following 1 Create A Function Called Piglatin That Accepts A String Of English Words In The 1 (147.04 KiB) Viewed 28 times
My output says:
Your Code Needs To Do The Following 1 Create A Function Called Piglatin That Accepts A String Of English Words In The 2
Your Code Needs To Do The Following 1 Create A Function Called Piglatin That Accepts A String Of English Words In The 2 (11.14 KiB) Viewed 28 times
It needs to say:
Your Code Needs To Do The Following 1 Create A Function Called Piglatin That Accepts A String Of English Words In The 3
Your Code Needs To Do The Following 1 Create A Function Called Piglatin That Accepts A String Of English Words In The 3 (20.75 KiB) Viewed 28 times
In Python
Your code needs to do the following: 1. Create a function called pigLatin that accepts a string of English words in the parameter sentence and returns a string of those words translated into Pig Latin. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding 'ay'. For example the sentence "The quick brown fox" becomes "hetay uickqay rownbay oxfay". You may assume the words in the parameter sentence are separated by a space. 2. Print the original sentence. 3. Print the Pig Latin sentence 4. Use the scrabble Tuples function, developed earlier, to produce a list of tuples of the Pig Latin words and their associated Scrabble scores. 5. Print the list of Pig Latin tuples. 1 # Write the function below 2 def pigLatin (sentence): pigLatinText = ""; for word in sentence.split(" "): 5 pigLatinText = pigLatinText + (word[1:] + word[0] + "ay") + " "; return pigLatinText 6 8 letter_values = {'a':1, 'b':3, 'c':3, 'd':2, 'e':1, 'f':4, 'g': 2, 'h':4, ''i':1, 'j':8, 'k':5, 'l':1, 'm':3, 'n':1, 'o':1, 'p':3, 'q':10, 'r':1, 's':1, 't':1, 'u':1, 'v':8, 'w':4, 'x':8, 'y':4, 'z':10} 9 10 11 12 def scrabbleValue (word): 13 total = 0 for i in word: 15 total + letter_values 16 return total 17 18 def scrabbleTuples (words): 19 tuples=[] 20 for i in range (len (words)): 21 if scrabbleValue (words) >= 8: 22 tuples.append( (words, scrabbleValue (words))) 23 return result 24 # Use the variable below to test 25 sentence = 'The quick brown fox jumps over the lazy dog' 26 27 # write your code below 28 pigLatinForm = pigLatin (sentence) 29 print (sentence) 30 print (pigLatinForm)

The quick brown fox jumps over the lazy dog heTay uickqay rownbay oxfay umpsjay veroay hetay azylay ogday

The quick brown fox jumps over the lazy dog he Tay uickqay rownbay oxfay umpsjay veroay hetay azylay ogday [('he Tay', 11), ('uickqay', 25), ('rownbay', 15), ('oxfay', 18), ('umpsjay', 21), ('veroay', 16), ('hetay', 11), ('azylay', 21), ('ogday', 10)]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply