Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
C++ program to check whether an Alphabet is Vowel or Consonant

Program to check whether an Alphabet is Vowel or Consonant in Python|3 ways

Posted on March 6, 2022

Table of Contents

  • Program to check whether an Alphabet is Vowel or Consonant in Python
    • Program to check whether Vowel or consonant
      • Code to check given Alphabet is Vowel or consonant using If else
      • Code to check given Alphabet is Vowel or consonant using If elif else
      • Code to check given Alphabet is Vowel or consonant using Ascii Value

Program to check whether an Alphabet is Vowel or Consonant in Python

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

Program to check whether Vowel or consonant

Code to check given Alphabet is Vowel or consonant using If else

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

Code to check given Alphabet is Vowel or consonant using If elif else

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

 

Code to check given Alphabet is Vowel or consonant using Ascii Value

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

if else in Python language

Operator in Python language

function  in python language

 

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

 

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes