Program to Count Vowels and Consonants in Python

Write a program in Python language to Count and display the number of vowels, consonants, uppercase, lowercase characters in a string. This python project is useful for beginners and CBSE KV School Class 11 and Class 12 students computer science practical file and NIELIT O Level module.

Objective of Program

Write a program in Python language to Count and display the number of vowels, consonants, uppercase, lowercase characters in a string.

Screenshot of python program to count vowels consonants with source code

Explanation of source code

string = input(“Enter Your String : “) #Entering the string
vowels = consonants = uppercase = lowercase = 0
vowels_list = [‘a’,’e’,’i’,’o’,’u’] #list of vowels
for i in string: #calculating the string elements for loop from start of first to end of the string.
if i in vowels_list:
vowels += 1
if i not in vowels_list:
consonants += 1
if i.isupper():
uppercase += 1
if i.islower():
lowercase += 1
print(“Number of Vowels in this String = “, vowels) #print system vowels, consonants ,uppercase and lowercase.
print(“Number of Consonants in this String = “, consonants)
print(“Number of Uppercase characters in this String = “, uppercase)
print(“Number of Lowercase characters in this String = “, lowercase)

Download source code of this program – click here

Output of count vowels consonants in Python

Testing

first string entered is : Archit is a great player.
here vowels:7
Consonants: 18
Upper case: 1
Lower case: 19
which is correct.
similarly
second string entered is : Super success insitute is located on jansath bypass
here vowels:10
Consonants: 22
Upper case: 1
Lower case: 26
which is correct.
Hence it is tested and program shows correct result.

Result

Counting Vowels Consonants in python of a string. The program is easy understandable code. Testing is done. This code gives correct output from the input which is a string. Calculating manually and by program is the same .

For more python programs – click here

Hello World Program in Python

Input a welcome message and display it in Python

Display the larger / smaller number in Python.

Greatest of Three Numbers in Python using Nested if

Patterns using nested loop in Python

Program to Print Pattern in Python

Program to input the value of x and n and sum of series in Python

Python Program for Armstrong, Prefect Number, Palindrome

Program of Prime number by recursion in python

Prime Number Program in Python

Write a Program to Print Fibonacci Series in Python

LCM and GCD program in Python

Python program to count number of vowels in a string

Whether a String is Palindrome or not in Python

Bubble Sort Program in Python

Linear search in python using list

Program to read a text file in python

Python program to read a file line by line

Program to Count Vowels and Consonants in Python

Stack Program in Python

Queue Program in Python

Python Leap Year Program for Beginners

Python Program to Print Series and Addition

Binary Search Program in Python

Program to find sum of digits in python

Sum of numbers divisible by 3 and 5 in python

error: Content is protected !!