Question

In python Please type the code Question 4: Write a program that reads an English word from the user, and prints how many vowels and how many consonants it contains. Note: You may assume the letter Y is not a vowel. Sample output (2 different executions) Enter a word: test test has 1 vowels and 3 consonants Enter a word: Apple Apple has 2 vowels and 3 consonants.

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

In the python program below, we have defined a list named vowList that stores all the vowels in the alphabet and have vows and cons variables to store the number of vowels and consonants int the word. Both initialized to 0.

We then read a word from the user and using a for loop, traverse the word character by character. In the for loop, we check if the character ch is in the vowList or not. If yes, then increment vows otherwise increment cons.

Finally we display the result as asked.

CODE:

main.py 1 #definig a list for all vowels 3 cons 4 vows0 5 word input(Enter a word: ) #reading word from user 6-for ch in wo

OUTPUT:

Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on 1inux Enter a word: House House has 3 vowels and 2 consonants

Add a comment
Know the answer?
Add Answer to:
In python Please type the code Question 4: Write a program that reads an English word...
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 python program that does the following: takes as input from the user an English...

    Write a python program that does the following: takes as input from the user an English sentence calls the function vc_counter() that: takes a string argument counts the number of vowels and consonants in the string returns a dictionary of the counts, using the keys total_vowels and total_consonants Uses the return from vc_counter() to print the total vowels and consonants with appropriate descriptions. Example: Enter an English sentence: The quick brown fox's jump landed past the lazy dog! Total #...

  • There are 21 consonants and 5 vowels in English. We wish to make a 4 letter...

    There are 21 consonants and 5 vowels in English. We wish to make a 4 letter combination as a password for an email account with 3 consonants and 1 vowel (assume all letters are lowercase, and no letter is repeated) How many different passwords can you make?

  • Char type: Edit the provided starter-code char_type.py so it takes the user to enter some text,...

    Char type: Edit the provided starter-code char_type.py so it takes the user to enter some text, then display the number of vowels, consonants,digits, and special characters in the text. In english the vowels are the letters "a" , "e" , "i", "o", "u", "y". All other letters are consonants. The digits are "0"-"9". The special characters are those that are not letters or digits. The program should countthe number of each type of character in the text user enters, then...

  • # 3. PUT IN PYTHON CODE # Write a program that prints a count of how...

    # 3. PUT IN PYTHON CODE # Write a program that prints a count of how many occurrences of the letter "a" # there are in q. Do to this you will have to use a loop within a loop. q = ["apple", "beans", "orange", "tangerine", "butter", "watermelon", "vinegar"] # Type your answer here:

  • 1. Write a python program that reads a file and prints the letters in increasing order...

    1. Write a python program that reads a file and prints the letters in increasing order of frequency. Your program should convert entire input to lower case and only counts letters a-z. Special characters or spaces should not be counted. Each letter and it's occurrences should be listed on a separate line. 2. Test and verify your program and it's output. ---Please provide a code and a screenshot of the code and output. Thank you. ----

  • Write a program in C plus plus that reads input a word at a time until...

    Write a program in C plus plus that reads input a word at a time until a lone q is entered.The program should then report the number of words that began with vowels, the num- ber that began with consonants,and the number that fit neither of those categories. One approach is to use isalpha() to discriminate between words beginning with letters and those that don’t and then use an if or switch statement to further iden- tify those passing the...

  • Please Use Python/IDLE language! Also, pleaseee include step by step algorithm. Python 3.4 Hawaiin Words program...

    Please Use Python/IDLE language! Also, pleaseee include step by step algorithm. Python 3.4 Hawaiin Words program help please. Hawaiian words can be intimidating to attempt to pronounce. Words like humuhumunukunukuapua'a look like someone may have fallen asleep on the keyboard. The language is actually very simple and only contains 12 characters; 5 vowels and 7 consonants. We are going to write a program that allows the user to enter a hawaiian word and give the pronunciation of the word or...

  • // Write a program that determines how many of each type of vowel are in an...

    // Write a program that determines how many of each type of vowel are in an entered string of 50 characters or less. // The program should prompt the user for a string. // The program should then sequence through the string character by character (till it gets to the NULL character) and count how many of each type of vowel are in the string. // Vowels: a, e, i, o, u. // Output the entered string, how many of...

  • Write a Python program to check whether a character entered as input is a vowel or...

    Write a Python program to check whether a character entered as input is a vowel or consonant. A vowel is any letter that is “a”, “e”, “i”, “o”, or “u”, and a consonant is all other letters. In addition, put in a statement that catches and prints out that “y” is either a consonant or a vowel. Example input: Please give a letter: aa Please enter only one letter: a Example output: Your letter a is a vowel.

  • Write python code on computer, No handwritten code You will implement a program which asks the...

    Write python code on computer, No handwritten code You will implement a program which asks the user to enter scores of different courses in different semesters. The program should read the input and output some simple statistics 1. An example input string by the user is given below. Fal12016-coursel:82, course2:80,course3:85;Spring2018- course4:82;Fall2018-course5:85, course6:50, course7:78 Info from different semesters are separated by a ";", courses in each semester are separated by a,and score and corresponding course is separated by a, information of...

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