Daily Archives: May 30, 2013

Python || Count The Total Number Of Characters, Vowels, & UPPERCASE Letters Contained In A Sentence Using A ‘For Loop’

Here is a simple program, which demonstrates more practice using the input/output mechanisms which are available in Python.

This program will prompt the user to enter a sentence, and then display the total number of uppercase letters, vowels and characters contained within that sentence. This program is very similar to an earlier project, this time, utilizing a for loop.

The highlighted portions are areas of interest.

Notice line 12 contains the for loop declaration. Note that each statement within the for loop block must be uniformly indented, otherwise the code will fail to compile.

Once compiling the above code, you should receive this as your output

Enter a sentence: My Programming Notes Is Awesome.

Total number of UPPERCASE letters: 5
Total number of vowels: 11
Total number of characters: 28

Python || Snippet – How To Input Numbers Into A List & Display Its Contents Back To User

This snippet demonstrates how to place numbers into a list. It also shows how to display the contents of the list back to the user via stdout.


Python Lists
For Loops

The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Once compiled, you should get this as your output

How many items do you want to place into the list?: 3

Enter item #1: 6
Enter item #2: 4
Enter item #3: 2008

The current items inside the list are:
Item #1: 6
Item #2: 4
Item #3: 2008