- Write a function called
initialVowel(words) (where words is a list of strings) that returns a new list of all of those strings that start with a vowel.
>>> initialVowel(['any', 'every', 'none', 'some', 'About'])
['any', 'every', 'About']
- Write a function called
pastWords(words) (where words is a list of strings) that returns a new list of all of those strings that end with "ed".
>>> pastWords(['helped', 'educate', 'replaced', 'asked', 'talking'])
['helped', 'replaced', 'asked']
- Write a function called
workable(words) (where words is a list of strings) that returns a new list of all of those strings that contain the substring "work".
>>> workable(['spark', 'rework', 'target', 'working', 'unworkable'])
['rework', 'working', 'unworkable']
- Write a function called
longPhrases(phrases, n) (where phrases is a list of strings) that returns a new list of all of those strings that contain n or more distinct words.
>>> longPhrases(['Star Wars', 'The Empire Strikes Back', 'Raiders of the Lost Ark', 'Titanic', 'The Terminator'], 4)
['The Empire Strikes Back', 'Raiders of the Lost Ark']
- Write a function called
fullProduct(nums) that returns the product of all of the elements of nums, a list of numbers. However, when computing the product, ignore any zero-valued elements.
>>> fullProduct([5,2,8,0,1])
80
>>> fullProduct([-3, -2, -1, 0, 1, 2, 3])
-36
- Write a function called
evenSum(nums) that returns the sum of
all even-numbered elements of nums, a list of numbers.
>>> evenSum([5,2,8,0,1])
10
>>> evenSum([-3, -2, -1, 0, 1, 2, 3])
0
- Write a function called
price(order) (where order is a string) that returns the price of a specified item. If the item is not among the examples below, the price is zero:
>>> price('hamburger')
1.55
>>> price('fries')
0.95
>>> price('soda')
1.15
- Write a function called
totalPrice(orderList) (where orderList is a list of strings) that returns the total price of all of
the items in the list. Your solution should call the price(order) function from the previous problem.
>>> totalPrice(['hamburger', 'soda', 'hamburger', 'fries', 'soda'])
6.35
- Write a function called
numVowels(word) (where word is a string) that returns the number of vowels contained in word.
>>> numVowels('wherever')
3
>>> numVowels('when')
1
>>> numVowels('why')
0
- Write a function called
avgVowels(words) (where words is a list of strings) that returns the average number of vowels in an element of words. Your solution should call the numVowels(word) function from the previous problem.
>>> avgVowels(['Oahu', 'Hawaii', 'Maui', 'Kauai', 'Molokai', 'Lanai', 'Niihau'])
3.5714285714285716