Description
The following includes concepts taught in Chapter 11
Write a python class library called Sentence that evaluates and manipulates an English sentence.
Your program will be called Sentence.py and contain the following class attributes and methods:
A constructor that takes a sentence string as input.
The default value for the constructor should be an empty string
Converts the sentence to a list attribute
o First remove all punctuation
The sentence must be a private attribute in the class
get_all_words — Method to get all the words in a sentence
Takes no arguments
Return: all the words in the sentence as a list
get_word — Method to get one desired word from the sentence
Arguments: Index location of desired word
Return: The single word or an empty string for a number outside the range
It is okay for the program to crash on a non‐integer argument
set_word — Changes the word at a given index location in sentence to a new word
Arguments: index, new_word
Does not return anything
The word change must persist within the instance
scramble – Scrambles the words in a sentence
Takes no arguments
Return: a scrambled list of all the words in a sentence
o This does not change the sentence attribute in your sentence instance
A repr method — use the built‐in method
Return: The sentence list as a single string, with a period at the end
In Sentence.py, include a unit test that does the following:
Runs inside an if __name__ block
Instantiates the class with a sentence of your choice
Validates set_word() method in that instance to demonstrate it works correctly
o Use assert command when checking for errors
At the end of your unit test, print:
o a message that the sentence worked correctly
For example Sentence unit test successful
o the original version of your sentence
o the scrambled version of your sentence
o the final version of your sentence
Where to submit?
Click Assignments in the Navigation Area and then click on the title of the assignment to enter the
submission area and upload your Sentence.py program. This should not be in a zip file.