46 Exercises: 16-20!!

16. Write a function filter_long_words() that takes a list of words and an integer n and returns the list of words that are longer than n.



17. Write a version of a palindrome recognizer that also accepts phrase palindromes such as “Go hang a salami I’m a lasagna hog.”, “Was it a rat I saw?”, “Step on no pets”, “Sit on a potato pan, Otis”, “Lisa Bonet ate no basil”, “Satan, oscillate my metallic sonatas”, “I roamed under it as a tired nude Maori”, “Rise to vote sir”, or the exclamation “Dammit, I’m mad!”. Note that punctuation, capitalization, and spacing are usually ignored.


18.A pangram is a sentence that contains all the letters of the English alphabet at least once, for example: The quick brown fox jumps over the lazy dog. Your task here is to write a function to check a sentence to see if it is a pangram or not.



19. “99 Bottles of Beer” is a traditional song in the United States and Canada. It is popular to sing on long trips, as it has a very repetitive format which is easy to memorize, and can take a long time to sing. The song’s simple lyrics are as follows:

99 bottles of beer on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall.

The same verse is repeated, each time with one fewer bottle. The song is completed when the singer or singers reach zero.

Your task here is write a Python program capable of generating all the verses of the song.EJ19



20. Represent a small bilingual lexicon as a Python dictionary in the following fashion {“merry”:”god”, “christmas”:”jul”, “and”:”och”, “happy”:gott”, “new”:”nytt”, “year”:”år”} and use it to translate your Christmas cards from English into Swedish. That is, write a function translate() that takes a list of English words and returns a list of Swedish words.EJ20


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s