- Write a function called
findFloats(s) that returns a list of strings corresponding to floating-point values.
>>> findFloats("3.1415, -2.71828, 4.0, 8.9, the value is 3.2, etc.")
['3.1415', '-2.71828', '4.0', '8.9', '3.2']
- Write a function called
findPrices(s) that returns a list of dollar-valued prices. This example uses prices.txt.
>>> prices = open("prices.txt").read()
>>> findPrices(prices)
['$3.25', '$13.75', '$0.75', '$1.25']
- Write a function called
findCapitalizedWords(s) that returns a list of words where the first letter only is capitalized.
- Write a function called
findSentences(s) that returns a list of sentences.
- These last two functions use the file
exoplanet.txt.
>>> ep = open('exoplanet.txt').read()
>>> findCapitalizedWords(ep)
['Seeing', 'Planets', 'From', 'Sun', 'Jupiter', 'Most']
>>> findSentences(ep)
['Seeing planets around other stars is hard.', 'Planets are faint, and stars\nbright.', 'From a distance, for example, the Sun is a billion times brighter\nthan Jupiter.', 'Most times, when we look at other stars, the planets are\ntotally lost on the glare.']