Please read the question first! Do not just copy a line of
the question, search, and copy and paste that answer here! I have
already put this question up and that is what the person that
answered it did. If that's all your going to do please do NOT
answer. I can do that myself and wouldn't waste my $.
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(""): pigLatinText = pigLatinText + (word [1:] + word[0] + "ay" return pigLatinText 7 8 letter_values= {'a':1, 'b':3, 'c':3, 'd':2, 'e':1, 'f':4, 'g': 2, 'h':4, 9 'i':1, 'j':8, 'k':5, 'l':1, 'm':3, 'n':1, 'o':1, 'p':3, 'q':10, 'r':1, 10 's':1, 't':1, 'u':1, 'v':8, 'w':4, 'x':8, 'y':4, 'z':10} 11 12 def scrabbleValue (word): 13 total = 0 14 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)] In Python My output says: It needs to say:
Please read the question first! Do not just copy a line of the question, search, and copy and paste that answer here! I
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am