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....

  • Write a Python program that stores the data for each player on the team, and it...

    Write a Python program that stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. Questions: - Handle the exception that occurs if the program can’t find the data file. - Handle the exceptions that occur if the user enters a string where an integer is expected. - Handle the exception that occurs if the user enters zero for the number of at bats. - Thoroughly test the...

  • 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!

  • C++ please no arrays! Create a program that will allow the user to enter up to...

    C++ please no arrays! Create a program that will allow the user to enter up to 50 whole values and determine the number of values entered, how many of the values were odd and how many of the values were even. Your code should contain 2 functions, a main function and a function to enter the numbers enter and count the values. Your main function should be a driver program that will call another function to count the total number...

  • Python homework problem First: Write a program (using a loop with break) to allow a user...

    Python homework problem First: Write a program (using a loop with break) to allow a user to input an integer and determine if the integer is prime. Then change the program to examine a number of integers to determine if each is prime. The program should allow the user to input the number of integers (say n) to be checked to determine if each is prime. Then the user should input n integers and print whether each of the integers...

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