Knowee
Questions
Features
Study Tools

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

Question

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

🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a Python program that accomplishes the task:

# Take character as input from the console
ch = input("Enter a character: ")

# Check if the character is a letter
if ch.isalpha():
    # If it is a letter, check if it is a vowel
    if ch.lower() in 'aeiou':
        print("letter and vowel")
    else:
        print("letter and consonant")
else:
    print("not letter")

This program works by first checking if the input character is a letter using the isalpha() function. If it is a letter, it then checks if it is a vowel by converting it to lowercase and checking if it is in the string 'aeiou'. If it is a vowel, it prints "letter and vowel", otherwise it prints "letter and consonant". If the input character is not a letter, it prints "not letter".

This problem has been solved

Similar Questions

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

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

Write a C program to check whether an alphabet is vowel or consonant using switch case

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

Write a program in C to count the number of vowels and consonants in a string. You can use fgets to read the characters.

1/3

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.