In this lesson we want to learn How to Find Vowel & Consonant Character in Python, Python is high level, interpreted and general purpose programming language. It was first released in 1991 by Guido van Rossum.
- Some of key features of Python include:
- Easy-to-read syntax: Python has simple and clean syntax and makes it easy to learn and write code for both beginners and experienced programmers.
- Dynamic Typing: Python uses dynamic typing, which means that you can assign values to variables without specifying their type. the type of variable is determined at runtime.
- Object-Oriented Programming: Python is an object oriented programming language, which means that it supports the creation of objects, classes and methods to model realworld objects.
- Large Standard Library: Python has large and comprehensive standard library that covers a wide range of tasks from web development to data analysis. this makes it easy to find and use pre written code for common tasks.
- Interoperability: Python can work seamlessly with other programming languages, making it easy to integrate with existing codebases and to use it in a variety of applications.
Python is widely used in different domains including scientific computing, data analysis, web development, artificial intelligence and many more. Its popularity is due in part to its ease of use, its large community of developers, and the many available libraries and tools that make it easy to accomplish complex tasks.
This is Python program to determine whether a character entered by the user is a vowel or consonant:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
def is_vowel(char): vowels = ['a', 'e', 'i', 'o', 'u'] if char.lower() in vowels: return True else: return False char = input("Enter a character: ") if is_vowel(char): print(f"{char} is a vowel.") else: print(f"{char} is a consonant.") |
In this program, a function is_vowel is defined to check if a given character is a vowel or not. The function takes a character as input, converts it to lowercase using the lower method and checks if it is present in the list of vowels. If it is present, the function returns True; otherwise, it returns False.
In the main part of the program, the user is asked to enter a character. The entered character is passed as an argument to the is_vowel function. Based on the return value of the function, the program prints a message indicating whether the character is a vowel or consonant.
(How to Find Vowel & Consonant Character in Python)
Learn More on Python
- Is Python Good for GUI Apps
- Is Python Good for Ethical Hacking
- Python Best Libraries for Web Development
- Top 10 Python REST API Frameworks
- How to Build REST API with Flask
- Build Python REST API with FastAPI
- Python Best Frameworks for Web Development