Python program to check given character is vowel or consonant

In this tutorial we are going to learn writing python program to check given character is a vowel ( a, e, i, o, u) or any other alphabet other than vowels(consonant) .

Problem statement

For any input character, we have to check whether a character is a vowel or consonant.

[elementor-template id=”5257″]

For example:

Case 1: If a user is given input a or A

              The output should be “Vowel”

              As we know that A is a vowel

Case2: If the user is given b or B

             The output should be “consonant”

             As we know that B is consonant

Our logic to check given character is vowel or consonant

  • Our program will take any character as an input from the user
  • Then checks if the character taken belongs to vowels or consonants, we achieve this using if-else conditional statements.

[elementor-template id=”5256″]

Algorithm to check given character is vowel or consonant

Step1:  Start

Step2    Take input from the user

Step3    Apply if-else condition,

                     if(vowel):

                            Print (‘vowel’)

                    else:

                           Print(’consonant’)

Step4 :  Stop

Python code to check given character is vowel or consonant

[elementor-template id=”5253″]

Output 1:

Explanation:

As we can see for the character ‘o’ output generated is “Vowel”, which is obvious as o is a vowel and satisfying the ‘if ’ statement  

Output 2:

Explanation:

Similarly, for the character ‘S’ output generated is “consonant”, as S is not a vowel and does not satisfy the ‘if ’ statement