Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Discuss the goals of financial management.

Answered: 1 week ago