Method 1:
Users can use built-in functions to check whether an alphabet is vowel function in python or not.
Algorithm:
Step 1: Get the input from the user as a ccharacter
Step 2: Using built-in python functions like (lower(), upper()), determine whether the input is vowel or consonant.
Step 3: If the character is a vowel, it should be printed. Otherwise, print Consonant if you don’t have a vowel.
Step 4: End
Source Code:
l = input("Enter the character: ")
if l.lower() in ('a', 'e', 'i', 'o', 'u'):
print("Vowel")
elif l.upper() in ('A', 'E', 'I', 'O', 'U'):
print("Vowel")
else:
print("Consonant")
Output:
Enter the character
e
Vowel
Method 2: Using the logical operator
ch = input("Enter the character : ")
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("Vowel")
else:
print("Consonant")
Output:
Enter the character:
M
Consonant
Related Questions
- How do you add to a matrix in python?
- How do you make a vowel counter in Python?
- How do I remove punctuation from a list in Python?
- How do you transpose a matrix in python?
- How do you find the sum of a matrix in python?
- How do you count the number of vowels in a list in Python?
- How do I remove punctuation from a text file in Python?
- How do you transpose in Python?
- How do you extract a vowel from a string in Python?
- How do you remove special and punctuation characters in Python?
- How do you add two matrices in Python using Numpy?
- How do I remove special characters from a list in Python?
- How do you transpose amatrix using Numpy in Python?
Leave a Reply