You are here

Exercises

4 September, 2015 - 14:38

There are solutions to these exercises in the next section. You should at least attempt each one before you read the solutions.

Exercise 9.2.In 1939 Ernest Vincent Wright published a 50,000 word novel called Gadsby that does not contain the letter e. Since e is the most common letter in English, thats not easy to do.

In fact, it is difcult to construct a solitary thought without using that most common symbol. It is slow going at rst, but with caution and hours of training you can gradually gain facility.

All right, Ill stop now.

Write a function called has_no_ethat returns Trueif the given word doesnt have the letter e in it.

Modify your program from the previous section to print only the words that have no e and compute the percentage of the words in the list have no e.

Exercise 9.3.Write a function named avoidsthat takes a word and a string of forbidden letters, and that returns Trueif the word doesnt use any of the forbidden letters.

Modify your program to prompt the user to enter a string of forbidden letters and then print the number of words that dont contain any of them. Can you nd a combination of 5 forbidden letters that excludes the smallest number of words?

Exercise 9.4.Write a function named uses_onlythat takes a word and a string of letters, and that returns Trueif the word contains only letters in the list. Can you make a sentence using only the letters acefhlo? Other than Hoe alfalfa?

Exercise 9.5.Write a function named uses_allthat takes a word and a string of required letters, and that returns Trueif the word uses all the required letters at least once. How many words are there that use all the vowels aeiou? How about aeiouy?

Exercise 9.6.Write a function called is_abecedarian that returns Trueif the letters in a word appear in alphabetical order (double letters are ok). How many abecedarian words are there?