Q. Write a program that should prompts the user to type some sentence (s) followed by “enter ”. it should then print the original sentence (s) and the following statistics relating to sentence (s):
(i) Number of words
(ii) Numbers of character (including white-space and punctuation )
(iii) Percentage of character that are alphanumeric.
You can understand by Watching video :-
Answer :-
sen = input("Enter a sentence = ") count = 1 alp = 0 for j in sen : if j == " " : count += 1 elif j.isalnum() : alp += 1 print("Number of word is ",count) print("Number of characters ",len(sen)) print("Percentage of alpha numeric = ", (alp / len(sen)) * 100)
Output :-
Enter a sentence = ? Welcome to our website Path Walla : )
Number of word is 9
Number of characters 39
Percentage of alpha numeric = 71.7948717948718
>>>
Enter a sentence = #Python is my Love?
Number of word is 4
Number of characters 19
Percentage of alpha numeric = 73.68421052631578
>>>
i cant understand percentage can you pl explain once
ReplyDeletePlease watch video video again . : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )