Professional Documents
Culture Documents
Date : 21/12/2021
Question # 1:
Write down the description, syntax and example of the following methods in python.
Question # 2:
Write a python program to take string phrase input from the user through
keyboard. The program should
be able to print the following.
(a) Total Vowels (upper or lower case character) in the given string phrase.
(b) Total Consonants (upper or lower case character) in the given string phrase.
(c) Total Spaces in the given string phrase.
(d) Total words in the given string phrase.
(e) Total characters in the given string phrase excluding spaces.
Code:
def strph(str):
vowels = 0
consonant = 0
totalwords = 0
totalchar = 0
totalspc = 0
totalwords=str.split()
totalwords=len(totalwords)
for i in range(len(str)):
if(str[i].isalpha()):
totalchar = totalchar + 1
print("Vowels:", vowels)
print("Consonant:", consonant)
print("Total Words:", totalwords)
print("Total Characters:", totalchar)
print("Total Space:", totalspc)