Header Ads Widget

Python program to input any alphabet and check whether it is vowel or consonant

 

 Python program to input any alphabet and check whether it is vowel or consonant

Given a character , write a program to check whether it is vowel or consonant . Vowels are (a ,e ,i , o , u ) and (  A , E , I , O , U) and except these characters all are consonants .

Sample input

f

Sample output

f is consonant

 Python program to input any alphabet and check whether it is vowel or consonant

The objective of the code is to check whether the character is vowel or consonants . 

Code(Python):-

ch=input()
if len(ch)>1:
print("Invalid input")
else:
if(ch=='A'or ch=='E'or ch=='I'or ch=='O'or ch=='U'or ch=='a'
or ch=='e'or ch=='i'or ch=='o' or ch=='u'):
print(f"{ch} is a vowel")
else:
print(f"{ch} is consonant")

Output:-


f
f is consonant

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-