CS 111: Introduction to Computer Science
Playing with strings
Hand in as: stringmenu/stringmenu.py
The program
As Chapter 4 of your textbook illustrates in some detail, Python provides you with lots
of ways of manipulating character strings. In this assignment, you will write a small
menu-driven program that will enable your user to experiment with some of
Python's 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. Capitalize all letters in the string.
B. How many characters are in the string?
C. Strip the white space from the beginning and end of the string.
D. Does the string contain the substring "goat"?
E. How many times does the letter "e" appear in the string?
Your choice?
Once the person makes a choice, the program should perform the requested task.
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.
Notes on handing in your code
- You can hand in your code in a couple ways. If you are working on Linux, you can use
HSP -- the Homework
Submission Program. If you are working on Mac or Windows, you can use the
Collab structure, saving your Python program as
Courses/f07/cs/cs111-00-f07/Student Work/yourusername/hand-in/stringmenu/stringmenu.py.
- It is important that you submit your programs using the folder and file names described
in the "Hand in as" line at the top of each assignment. This will help the grader and me
easily find and test your code.
- Always put your name, the date, and a brief description of your program in a comment at
the top of the program, as in my examples.
- If you work with a partner, put both names in the comment at the top of your source code.
- If you work with a partner, hand in only one copy of your assignment--it doesn't matter to
which person's account.
Start early, have fun, and keep in touch.