CS 111: Introduction to Computer Science

Menus, functions, and strings

Due by 8:30AM Monday, April 13.

Hand in as: menu.py

The program

For this assignment, you'll get the opportunity to apply your knowledge of loops, conditionals, and functions to create a small menu-driven program that will enable your user to play with strings. You may wish to use some of Python string methods.

When a person executes your program, your program should ask the person to enter a string. Next, the following menu should appear:

A. Is the string a palindrome? B. How many vowels are in the string? C. How many times does the substring "the" appear in the string? D. Quit Your choice?

Once the person makes a choice, the program should perform the requested task. If the person chooses D, then the program should terminate. Otherwise, the process should continue--ask the user for another string, print the menu, get a choice, etc.

For the purposes of this assignment, you may assume that a string is a palindrome only if it is exactly the reverse of itself. Thus, "rats live on no evil star" will be a palindrome, but "sit on a potato pan, Otis." will not. (If you wish to write a more sophisticated palindrome tester that ignores punctuation, capitalization, and spacing, feel free to do so.)

Also, let's pretend that the letter y is never a vowel.

To get started, save and run this program: menu.py. This program illustrates a simple menu-and-response structure that you can adapt for this assignment.