Question

Using PYTHON create a program to allow the user to enter a phrase or read a...

Using PYTHON create a program to allow the user to enter a phrase or read a file.

Make your program menu-driven to allow the user to select a option to count the total words in the phrase or file. In addition, provide a menu-selection to count the number of words start with a vowel and a selection to count the number of words that start with a consonant.

Include exception handlers for file not found, divide by zero, and index error. Include a generic exception handler to all you to capture any exceptions not handled by the try-except block.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Whether you face any problem or need any modification then share with me in the comment section, I'll happy to help you.

1 from contextlib import suppress 2 3 4. 5 6 7 # Function returns true if s vowel otherwise false def is vowel(s): if s.isalp

21 22 23 24 25 26 27 28 29 30 31 32 33 with suppress (Exception): f = open(input.txt) # open filename for reading wordlist

38 39 40 41 42 43 44 45 if op == 1: print(The total number of words = , len(wordlist)) elif op == 2: count = 0 for word in

Input File: input.txt

The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog

Output:

1. Count the total words 2. Count the total words start with a vowel 3. Count the total words start with a consonant 4. Exit

Add a comment
Know the answer?
Add Answer to:
Using PYTHON create a program to allow the user to enter a phrase or read a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a javafx GUI program that uses a TextField to allow the user to enter a...

    Write a javafx GUI program that uses a TextField to allow the user to enter a string. When the user presses return, have the action handler for the TextField count the number of vowels (a, e, i, o, u, y) in the string. Use a switch statement for this rather that if statements. Write out the number of vowels in a Label. Case does not matter for the vowels.

  • A Web Crawler Write a Python program to allow the user to enter a valid URL....

    A Web Crawler Write a Python program to allow the user to enter a valid URL. Have the program read the URL, storing each unique link in the page, visit each link, obtain and display the title from each site visited. Upload correctly working program file here.

  • Create a program in Python that will allow the user to enter a temperature in Fahrenheit...

    Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...

  • Starting out with python 4th edition Write program that lets the user enter in a file...

    Starting out with python 4th edition Write program that lets the user enter in a file name (numbers.txt) to read, keeps a running total of how many numbers are in the file, calculates and prints the average of all the numbers in the file. This must use a while loop that ends when end of file is reached. This program should include FileNotFoundError and ValueError exception handling. Sample output: Enter file name: numbers.txt There were 20 numbers in the file....

  • USING PYTHON *Write a program, in which the user enters two numbers, then divides the first...

    USING PYTHON *Write a program, in which the user enters two numbers, then divides the first number by the second, and prints the result to two decimal places. *Make sure that that the inputs are floats (with exception handling using the ValueError). *Make sure that there is no divide by zero error (with exception handling). *Then have a plain exception: That handles any other error. -Thank you in advance for your assistance-

  • Division by Zero Problem: Create a program titled Division. Have the program prompt the user "Enter...

    Division by Zero Problem: Create a program titled Division. Have the program prompt the user "Enter numerator and denominator" and store the two values entered. (If you wish the user to "Enter numerator/denominator" be sure to adjust your data gathering variables to include a holder variable for the slash character.) Include a function titled Quotient that takes 2 integers as input and provides the quotient of the 2 integers as integer output. (The remainder is truncated. Thus, 5/3 will be...

  • Can someone make a python program that would allow the user to enter any amount of...

    Can someone make a python program that would allow the user to enter any amount of numbers and multiply each number entered by 23.6%, 38.2%, 50%,61.8%,78.6%,113%,123.6%,138.2% and 161.8%. Every number the user enters get multiplied by every percent stated and the answer's will be produced in a excel like format where answers are lined up horizontally. Thank you so much to anyone who helped!

  • Python Error: Writing a program to complete the following: Prompt the user for the name of...

    Python Error: Writing a program to complete the following: Prompt the user for the name of an input file. Open that file for input. (reading) Read the file using a "for line in a file" loop For each line,  o print the line and compute and print the average word length for that line. Close the input file Sample output: MY CODE IS WRONG AND NEED HELP CORRECTING IT!!! ------------------------------------------------------------------------------------------------------------------------ DESIRED OUTPUT: Enter input file name: Seasons.txt Thirty days hath September...

  • Read description carefully. Needs to catch exceptions and still be able to keep the program going...

    Read description carefully. Needs to catch exceptions and still be able to keep the program going on past the error. Program should allow user to keep going until he or she quits Math tutor) Write a program that displays a menu as shown in the sample run. You can enter 1, 2. 3, or 4 for choosing an addition. subtraction, multiplication, or division test. After a test is finished, the menu is redisplayed. You may choose another test or enter...

  • Python please Create a menu-driven modular program so user can take a 10-question math quiz, Addition...

    Python please Create a menu-driven modular program so user can take a 10-question math quiz, Addition or subtraction, at specified difficulty level. Easy(1-digit), Intermediate(2-digit), and Hard(3-digit). After a quiz, display the quiz type and level, and number of correct questions user answered.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT