Question: Write a python class library that evaluates and manipulates an English sentence. *** Use this sentence: The long hungry python, moved to capture the weak

Write a python class library that evaluates and manipulates an English sentence.

*** Use this sentence: "The long hungry python, moved to capture the weak mouse"

Create a class called Sentence that is in a file called Sentence.py and contains class attributes and methods as follows:

+ 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: Number of the desired word, starting at 1

-Return: The single word or an empty string for a number outside the range

-It is okay for the program to crash on a noninteger argument

-The word change must persist within the instance

+set_word Changes the word at a given index in sentence to a new word

-Arguments: index, new_word

-Does not return anything

+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 builtin method

-Return: The sentence list as a single string, with a period at the end

In Sentence.py, include a unit test

+Place inside an if __name__ block

+Instantiate the class with a sentence of your choice

+Validate that the public methods in that instance work correctly

o Use assert to check for errors

+At the end of your unit test, print a message that the sentence worked correctly and include

the final version of your sentence.

o For example Sentence unit test successful: my sentence

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!