Question: 1. write a function named odd_squared_v1 that builds a list of the odd numbers from 1 to 100 (inclusive) squared. Do NOT use comprehensions. 2.
1. write a function named odd_squared_v1 that builds a list of the odd numbers from 1 to 100 (inclusive) squared. Do NOT use comprehensions.
2. write a function named odd_squared_v2 that builds the same list but uses a list comprehension.
3. write a function named is_palindrome which returns True if the parameter (a string) is a palindrome or False if it is not. A palindrome is a string/word that reads the same forward as backwards (e.g. noon, mom, racecar). A word is a palindrome even if the case of the letters is different (e.g Civic is still a palindrome) As a note, algorithms for determining if a word is a palindrome are all over the internet. However, you must solve this using only the syntax you have seen using string and list methods (https://docs.python.org/3.6/tutorial/datastructures.html#more-on-lists). It will serve your brain well to solve this yourself.
4. write a function named build_palindrome_map which takes a sentence and returns a dictionary of the words as keys and a boolean for their value (indicating if the word is a palindrome or not). You should use your fancy function from part 3. You can use assume the sentence does not have any punctuation and words are separated by only whitespace The keys in the dictionary should be the unmodified words from the sentence
The phrase: Never Odd Or Even is also a palindrome. How would you use your function (in part 3) to test a phrase? This not required for passing tests.
5. write a function called build_all_dice_pairs that generates tuples that represent all permutations of two dice throws. You must use a single comprehension to solve this. See if you can get all the pairs in the list to have the lower dice value first (but not required to pass the tests).
starter code
def common_letters(strings): result = set(strings[0]) for string in strings: result = result.intersection(set(string)) return result # write your testing code here # e.g answer = lesson.is_palindrome('rotator')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
