Today, we are going to discuss a python program, which will print a string and count number of vowels in Python. The python program is to print a string and calculation of number of vowels ,which will be discussed. This basic python program is very useful for beginners, CBSE Class 11 and 12 Computer Science and Project Practical file.
String – A groups of alphabets and special characters included.
vowels- A vowel is in alphabets, these are the following – a,i,e,o,u
#WAP to print a string and the number of vowels present in it
Source Code and Execution of Program
st=input(“Enter the string”) #enter the string which you want to show and calculate vowels.
print(“Entered string =”,st) # The input string is shown as output
st=st.lower() #the string is lower casse and save in st
c=0 #vowel counter is set to zero
v=[‘a’,’e’,’i’,’o’,’u’] # vowels are these numbers a,e,i,o,u
for i in st: # for loop from starting of string to the last iteration with last character of string.
if i in v: #it checks whether the character is same as in v.
c+=1 #the characters increases in value 1,2,3 if character is a vowel.
print(“Number of vowels in entered string =”,c) Then the number of vowel string is shown with the number of vowel
Output of Printing a string and number of vowels in Python
Here we have given input string as – It is a good view of waterfall.
It first shows the string typed as output. Then calculate the number of vowels. which is 11.
Similarly the next string this way you look more beautiful is printed and the vowels are calculated which is 13.
Source code of WAP to print a string and the number of vowels present in it- click here
Thanks for reading this Python program to count number of vowels in a string.
For more python programs- click here
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
Python program to count number of vowels in a string
Whether a String is Palindrome or not 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
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