Check whether the given character is a Vowel or ConsonantInput Format:Enter a Character as input Output Format:Print the output as "Vowel" or "Consonant" Constraints:0 <= letter <= 2^7Sample Input 1:tSample Output 1:Consonant
Question
Check whether the given character is a Vowel or ConsonantInput Format:Enter a Character as input Output Format:Print the output as "Vowel" or "Consonant" Constraints:0 <= letter <= 2^7Sample Input 1:tSample Output 1:Consonant
Solution
To check whether a given character is a vowel or a consonant, follow these steps:
- Read the input character.
- Check if the input character is equal to 'a', 'e', 'i', 'o', or 'u'. These are the vowels in the English alphabet.
- If the input character is equal to any of the vowels, print "Vowel".
- If the input character is not equal to any of the vowels, print "Consonant".
Here is the code in Python:
# Step 1: Read the input character
character = input("Enter a character: ")
# Step 2: Check if the character is a vowel
if character.lower() in ['a', 'e', 'i', 'o', 'u']:
# Step 3: Print "Vowel" if it is a vowel
print("Vowel")
else:
# Step 4: Print "Consonant" if it is not a vowel
print("Consonant")
Note: The code assumes that the input character is a single alphabet character.
Similar Questions
Take character as input from the console using input() function. Write a program to check whether the given input is a vowel or a consonant or a letter are not. Print the result to the console as shown in the examples.Sample Input and Output 1:ch: Aletter and vowelSample Input and Output 2:ch: Pletter and consonantSample Input and Output 3:ch: @not letter
Adam, while helping his niece with her homework, needs to check if a given lowercase character is a vowel or consonant. Can you write a program to assist Adam in determining this? Input format :The input consists of a lowercase character.Output format :The output prints whether the given character is a vowel or consonant.Refer to the sample output for the exact text.Code constraints :The input should only be a lowercase character.Sample test cases :Input 1 :aOutput 1 :a is a vowelInput 2 :sOutput 2 :s is a consonant
Check whether the given character is an alphabet or a numeric character or special characterInput Format:Enter a Character as inputOutput Format:Print the output as "NUMBER" or "ALPHABET" or "SPECIAL CHARACTER"Constraints:0 <= CHARACTER <= 2^7Sample Input 1:7Sample Output 1:NUMBERSample Input 2:aSample Output 2:ALPHABET
Write a program that will take one string as input. The program will then remove vowels a, e, i, o, u (in lower or upper case) from the string. If there are two or more than two vowels that occur together then the program shall ignore all of those vowels.Sample input Cat Sample output CtSample input HeelSample output Heel
Words, Vowels and ConsonantsProblemSubmissionsLeaderboardGiven a sentence containing only uppercase/lowercase english alphabets and spaces, you have to count the number of words, vowels and consonants.Input FormatFirst line of input contains T - number of test cases. Its followed by T lines, each line contains a single sentence.Constraints1 <= T <= 10001 <= len(sentence) <= 104Output FormatFor each test case, print the number of words, vowels and consonants, separated by newline.Sample Input 04HiHello World Exception Hi thereSample Output 01 1 12 3 71 4 52 3 4
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.