Intro to Python Classwork: Sentence Stats
Write a Python program named "SentenceStats.py" that has the user
enter a sentence (with a "sentence" considered to be any combination
of one or more words).
Then report to the user the following information:
1) How many words are in the sentence
2) How many vowels are in the sentence
3) How many consonants are in the sentence
4) How many non-letter characters (numbers, spaces, punctuation)
are in the sentence
5) How many uppercase letters are in the sentence
6) How many lowercase letters are in the sentence
7) The shortest word in the sentence
8) The longest word in the sentence
When determining #1, #7, and #8 above, consider a word to be any
combination of characters that has a space on either or both sides.
The one exception is if the user enters only one word (no spaces).
For #7 and #8 above, if there are multiple shortest/longest words
of the same length, display all of them.
Unlike your previous Python assignments, you must use a separate
function to get your user input, as well as separate functions for
each of the eight tasks above. The "main" area of your program
should consist almost exclusively of variable declarations and
calls to the individual functions.
You may not import or use any external functions, including the
Python 'min' and 'max' commands. You may, however, use global
variables in your program. Your program's output should be neat,
organized, and easy to read/understand.
As always, all of your code must be your own, written entirely and
only by you within your online CodeHS.com account. You must never
copy/paste, receive, view, or in any way use code that was created
or modified by another person, entity, or artificial intelligence.
Advanced Option #1
After displaying the information described above, tell the user
if the sentence is a palindrome. A palindrome is a letter, word,
or phrase that, after removing spaces and punctuation (everything
that is not a letter), and ignoring case, is identical when
displayed forwards and backwards. For example, the following are
all considered to be palindromes:
radar
Was it a cat I saw?
Lewd did I live, & evil I did dwel.
Straw? No, too stupid a fad, I put soot on warts.
Advanced Option #2
After displaying the information described above, convert each
word in the sentence to Pig Latin. The Pig Latin conversion
rules are as follows:
First Pig Latin rule: If the word does not contain any vowels
(a-A-e-E-i-I-o-O-u-U), just add "ay" to the end of the word.
Second Pig Latin rule (to be followed only if the first rule
does not apply): If the first letter in the word is a vowel,
just add "yay" to the end of the word.
Third Pig Latin rule (to be followed only if the above two rules
do not apply): Move all leading consonants to the back of the
word, and then add "ay" to the end of the new word.
Final Pig Latin rule (to be followed after the above third rule):
If the original word started with a capital letter, make it
lowercase and instead capitalize the first letter of the new word.
For example, if the original sentence is
Why do they think you and Sheena should return immediately?
then the Pig Latinated sentence is
Whyay oday eythay inkthay ouyay andyay Eenashay ouldshay eturnray immediately?yay
This option may be completed along with, or instead of, the first
advanced option.