Answered step by step
Verified Expert Solution
Question
1 Approved Answer
help with this code please, with explanations if you can. thank you! 2. Write a function scrabble_score(word) that takes as input a string word containing
help with this code please, with explanations if you can. thank you!
2. Write a function scrabble_score(word) that takes as input a string word containing only lowercase letters, and that uses recursion to compute and return the scrabble score of that string - i.e., the sum of the scrabble scores of its letters. For example: In addition to calling itself recursively, the function must also call your letter_score function to determine the score of a given letter. Doing so will allow you to avoid repeating the long if-elif-else statement that is already present in letter_score. Indeed, the only if-else statement that you should need is the one that determines whether you have a base case or recursive case. 3. Write a function BUtify(s) that takes as input an arbitrary string s and uses recursion to determine and return a new string in which all lower-case bs are replaced by upper-case Bs and all lower-case us are replaced by upper-case Us. For example: >> BUtify('you be you') result: 'you Be you' > BUtify('beautiful') result: 'BeaUtiful' > BUtify ('unbelievable') result: 'UnBelievaBle' 4. Write a function diff(vals1, vals 2 ) that takes as inputs two arbitrary lists of non-negative integers vals1 and vals2 and uses recursion to construct and return a new list in which each element is the the absolute value of the difference of the corresponding elements from the original lists. For example: diff([3,4,2,5],[7,2,9,5]) result: [4,2,7,0] In the return value for this case: - The first element is 4 , because the difference of the first elements in the original lists is 37=4, and we multiply by 1 to get the absolute value. - The second element is 2 , because the difference of the second elements in the original lists is 42=2, and we don't need to adjust it because 2 is already non-negative. - The third element is 7 , because 29=7, and we multiply by 1 to get the absolute value. - The fourth element is , because 55=0. Important You may not use Python's built-in function for computing the absolute value of a number. Rather, you will need to use conditional execution to determine whether you need to adjust the result of subtracting a given pair of elements. Here are two other examples: If one of the lists is longer than the other, its "extra" elements - the ones with no counterparts in the shorter list - should appear immediately after the differences (if any) in the returned list. For exampleStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started