Question: Python Exercise: 1. Create a new class called Sentence. 2. Create the constructor to take a single parameter that is a string. the value should

Python Exercise:

1. Create a new class called Sentence.

2. Create the constructor to take a single parameter that is a string. the value should be stored as a string in a instance variable(assume the sentence has no punctuation).

3. Write the following accessor methods:

a) getSentence()-returns the sentence as a string

b) getWords()- returns the list of words in the sentence(use str.split())

c) getLenght()- returns the number of characters in the sentence

d) getNumWords()- returns the number of words in the sentence

4. Write a mutator method that allows you to capitalize the letters in a sentence.

5. Write a mutator method that allows you to add a punctuation mark to the end of the sentence.

6. Add a __str__() method.

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 Databases Questions!