Table of Contents
In this article, we will discuss the concept of Program to check whether an Alphabet is Vowel or Consonant in Python
In this post, we are going to learn how to write a program to check whether given English alphabet is Vowel or Consonant using various ways in Python language
In this code, we are going to learn how to check the given English alphabet is Vowel or consonant using if-else in Python language
Program 1
#Python code to check whether a character is vowel or consonant ch=input("Please enter the character as you wish: ") #take input from the user if(ch== 'a'or ch== 'A'or ch== 'e'or ch== 'E'or ch== 'i' or ch=='I' or ch=='o' or ch=='O' or ch=='u' or ch=='U'): #if part - check whether the given character is vowels print("the given character ",ch," is vowel"); #else part - displays whether the given character is consonant else: print("the given character ",ch," is consonant");
When the above code is executed, it produces the following result
Case 1
Please enter the character as you wish: U the given character U is vowel
Case 2
Please enter the character as you wish: t the given character t is consonant
In this code, we are going to learn how to check the given English alphabet is Vowel or consonant using if-elif-else in Python language
Program 2
#Python code to check whether a character is vowel or consonant ch=input("Please enter the character as you wish: ") if ch.lower() in('a','e','i','o','u'): print(ch," is vowel"); elif ch.upper() in('A','E','I','O','U'): print(ch," is vowel"); else: print(ch," is consonant")
When the above code is executed, it produces the following result
Case 1
Please enter the character as you wish: A the given character A is vowel
Case 2
Please enter the character as you wish: n the given character n is consonant
In this code, we are going to learn how to check the given English alphabet is Vowel or consonant using Ascii value in Python language
Program 3
#Python code to check whether a character is vowel or consonant ch=input("Please enter the character as you wish: ") if(ord(ch)== 65 or ord(ch)== 69 or ord(ch)== 73 or ord(ch)== 79 or ord(ch)== 85 or ord(ch)==97 or ord(ch)==101 or ord(ch)==105 or ord(ch)==111 or ord(ch)==117): print("the given character ",ch," is vowel"); else: print("the given character ",ch," is consonant");
When the above code is executed, it produces the following result
Case 1
Please enter the character as you wish: y the given character y is consonant
Case 2
Please enter the character as you wish: I the given character I is vowel
Suggested post
Similar post
Java program to print all alphabets in given range
C program to print all alphabets in given range
C++ program to print all alphabets in given range
Java program to print all alphabets using loops
C program to print all alphabets using loops
C++ program to print all alphabets using loops
Java program to find whether a character is Alphabet or Not
C++ program to find whether a character is Alphabet or Not
C program to check whether a character is Alphabet or Not
Python program to check whether a character is Alphabet or Not
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.