[Type C]Q3. Write a program that should prompt the user to type some sentence(s) followed by “enter”. It should then print the original sentences and the following statistics relating to the sentences.

Alphanumeric: A character that is either a letter or a number.

isalnum() function in Python programming language checks whether all the characters in a given string is alphanumeric or not.

Program code:


Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

Enter a sentence: Hello! Welcome to Computer Tutor!! Number of words is 5 
Number_of_characters are 34 
Percentage of characters that are alphanumeric is 79.41176470588235 %

Input a sentence from the user. The number of words in initiated to 1 and on incurring white space the count of words is increased.

Characters are counted using the len() function.

On getting the count of both words and characters, the percentage of alphanumeric characters is calculated.

Basic python functionality is demonstrated in above program.

To view all the lessons in chapter 1: http://computertutor.in/class-12-computer-science/chapter-2/

To view entire class 12 computer science study material: http://computertutor.in/resources/

You cannot copy content of this page