9.9k views
4 votes
Write a menu driven program which will allow the user to enter a string and then

select an analysis option (opt):
opt 1 character count in string (lower and upper case letters)
opt 2 vowel count (aeiou and AEIOU)
opt 3 consonant count (lower and upper case letters which are not vowels)
opt 4 most frequent character (lower and upper case letters)
Create a stringanalysis.py package for import into your main program file. The
stringanalysis package should contain the following functions:
menu() returns an opt value (1,2,3,4)
characters (mystr) - returns the number of characters in mystr
vowels (mystr) returns the number of vowels in mystr
consonants (mystr) returns the number of consonants in mystr
freqchar (mystr) returns the most frequent character in mystr
Use a bottom up approach to your development. Code the five functions above -
one at time check each one using a temporary main driver. Develop the overall
main last.
Name your program with main(), fileprefixlab07.py. Block comments at the top as
usual. Next get the stringanalysis package:
import stringanalysis as in
The main() function should first call the menu function from the stringanalysis
package. Then use selection structures based on the opt value to call the other
analysis functions as needed.
Be sure to include sample results with triple quoted comments at the bottom of
your file. Use these three strings as samples:
String 1: "Now is the Time to Call 911!"
String 2: "Check out property are 123 N. Main St."
String 3: "Can you call before 1:20 appointment with Quinn Zubel?"
Use two more strings of your choice and include in your output at the bottom of
the file.

User Sbarzowski
by
7.3k points

1 Answer

4 votes

Final answer:

The student's question involves building a Python program that analyses strings through a variety of functions encapsulated in a package named stringanalysis. The program will count characters, vowels, consonants, and find the most frequent character based on user input. Each function's accuracy is verified before incorporation into the main program.

Step-by-step explanation:

The question pertains to creating a menu-driven program in Python, which involves writing a package called stringanalysis and a main file named fileprefixlab07.py. The package includes functions like characters(mystr), vowels(mystr), consonants(mystr), and freqchar(mystr), which are used to analyze a given string based on the user's selection from the menu. The main program calls these functions depending on the analysis option chosen by the user and the menu() function which returns the option selected by the user. The correctness of each function should be verified by a temporary main driver before developing the overall main function.

The program should handle scenarios like character counting (option 1), vowel counting (option 2), consonant counting (option 3), and identifying the most frequent character in the string (option 4). After completing the functions in the stringanalysis package, they should be imported and used in the main program according to the menu-driven options selected by the user.

User Johnnyboy
by
9.1k points