CS 111: Introduction to Computer Science
Winter 2017
HW05: Menu-driven string functions
Due: Monday, 01/23 at 22:00
If you are pair programming, do NOT start coding without your partner.
You should read the assignment first, feel free to think about it, but do not actually start coding.
Your task
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. How many characters are in the string?
B. How many letters are in the string?
C. How many vowels are in the string?
D. Is the string a palindrome?
E. What is the Caesar Cipher (shift 3) of the string?
Q. Quit
Your choice:
Once the person makes a choice, the program should perform the requested task.
If the person chooses Q
, then the program should terminate. Otherwise, the
process should continue: ask the user for another string, print the menu, get
a choice, etc.
A little help
-
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
is a palindrome, butsit on a potato pan, Otis.
is not. - The string
Table tennis is a sport!!
contains 25 characters, 19 letters, and 7 vowels. - Let's pretend that the letter
y
is never a vowel. - To get started, save and run
menu.py
. This program illustrates a simple menu-and-response structure that you can adapt for this assignment. (As always, give credit where credit is due.)
Optional extensions
- Write a more sophisticated palindrome tester that ignores punctuation, capitalization, and spacing.
- Starting in the second time asking for a string, present the previous input as the default value if the user does not type anything.
Grading
Please name your filemenu.py
. This makes it a little easier for the grader.
- Style/comments [3 points]
- All the style guidelines from previous assignments, as always.
- All your code should be in functions,
main
or otherwise.
- main menu [4 points]
- menu options [9 points]
Start early, have fun, and discuss questions on Moodle.