sing PYTHON: The instances of this class have the following attributes: word_count, status, grade, asked_grade_before_submission_count and the followin et_grade, str. For this exercise, we will add the following attribute/s: ) key - a class attribute that determines the output when printing the document instance. It has a value of 0 by default. et us also add these additional method/s for the Document class: ) copy_content - takes in source_document as a parameter of type Document then updates the word_count of the destination document (or the document wh ord_count is updated accordingly so that the content of the destination document is replaced by the source document. ) append_content - takes in source document as a parameter of type Document then updates the word_count of the destination document. The word_count e source document is appended to the destination document. put Format he inputs are commands that can access an attribute or invoke a method of a Document instance. These commands can either be valid or invalid.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Create a Python class, Document.
Using PYTHON: The instances of this class have the following attributes: word_count, status, grade, asked_grade_before_submission_count and the following methods: add_words, submit,
get_grade,_str_. For this exercise, we will add the following attribute/s:
(1) key - a class attribute that determines the output when printing the document instance. It has a value of 0 by default.
Let us also add these additional method/s for the Document class:
(1) copy_content - takes in source_document as a parameter of type Document then updates the word_count of the destination document (or the document where this method was invoked). The
word_count is updated accordingly so that the content of the destination document is replaced by the source document.
(2) append_content - takes in source_document as a parameter of type Document then updates the word_count of the destination document. The word_count is updated such that the content of
the source document is appended to the destination document.
Input Format
The inputs are commands that can access an attribute or invoke a method of a Document instance. These commands can either be valid or invalid.
Constraints
String arguments when creating a Document instance and when invoking the add_words method will be limited to 1000 characters at maximum. Only alphanumeric characters will be used as an
argument to these methods.
The invalid commands only include those that are trying to access an attribute of the object that is undefined.
Output Format
The output will be composed of 5 - 6 lines. The first five lines show the stats of the document being printed. The other is either an empty string or a string that shows one out of many descriptions
of the Document instance being printed.
Sample Input 0
essay
classes ['essay'] = essay
essay_draft
Document ("Violets are blue")
classes ['essay_draft'] = essay_draft
essay.append_content (essay_draft)
essay.key = 0
exit
Sample Output 0
Valid command
Valid command
Valid command
Valid command
Valid command
Document ("Roses are red")
Valid command
This Document instance has the following stats.
1. word count: 6
2. status: draft
3. grade: awaiting submission
4. number of times the grade was requested before the document was submitted: 0
Sample Input 1
essay Document ("Roses are red").
classes ['essay'] = essay
essay_draft
classes ['essay_draft'] = essay_draft
exit
essay.append_content (essay_draft)
another essay_v2 = Document ("Go away Anna! Okay bye.")
essay.copy_content (another_essay_v2)
essay.key=0
Document ("Violets are blue")
Sample Output 1
Valid command
Valid command
Valid command
Valid command
Valid command
Valid command
Valid command
Valid command
This Document instance has the following stats.
1. word count: 5
2. status: draft
3. grade: awaiting submission
4. number of times the grade was requested before the document was submitted: 0
Sample Input 2
essay Document ("Roses are red")
classes ['essay'] = essay
essay_draft
classes ['essay_draft'] = essay_draft
Document ("Violets are blue")
essay.append_content (essay_draft)
essay.add_words ("Sugar is sweet and so are you")
essay.key_1
essay.delete()
essay.key = 0
exit
Sample Output 2
Valid command.
Valid command
Valid command
Valid command
Valid command
Valid command
Invalid command
Invalid command
Valid command
This Document instance has the following stats.
1. word count: 13.
2. status: draft
3. grade: awaiting submission
4. number of times the grade was requested before the document was submitted: 0
Sample Input 3
Document ("Roses are red").
essay
classes ['essay'] = essay
essay_draft Document ("Violets are blue").
classes ['essay_draft'] = essay_draft
essay.append_content (essay_draft).append_content (essay_draft)
essay.add_words ("Sugar is sweet and so are you")
essay.key_1
essay.delete()
essay.key=0
exit
Sample Output 3
Valid command
Valid command
Valid command
Valid command
Valid command
Valid command
Invalid command
Invalid command
Valid command
This Document instance has the following stats.
1. word count: 16
2. status: draft
3. grade: awaiting submission
4. number of times the grade was requested before the document was submitted: 0
Transcribed Image Text:Create a Python class, Document. Using PYTHON: The instances of this class have the following attributes: word_count, status, grade, asked_grade_before_submission_count and the following methods: add_words, submit, get_grade,_str_. For this exercise, we will add the following attribute/s: (1) key - a class attribute that determines the output when printing the document instance. It has a value of 0 by default. Let us also add these additional method/s for the Document class: (1) copy_content - takes in source_document as a parameter of type Document then updates the word_count of the destination document (or the document where this method was invoked). The word_count is updated accordingly so that the content of the destination document is replaced by the source document. (2) append_content - takes in source_document as a parameter of type Document then updates the word_count of the destination document. The word_count is updated such that the content of the source document is appended to the destination document. Input Format The inputs are commands that can access an attribute or invoke a method of a Document instance. These commands can either be valid or invalid. Constraints String arguments when creating a Document instance and when invoking the add_words method will be limited to 1000 characters at maximum. Only alphanumeric characters will be used as an argument to these methods. The invalid commands only include those that are trying to access an attribute of the object that is undefined. Output Format The output will be composed of 5 - 6 lines. The first five lines show the stats of the document being printed. The other is either an empty string or a string that shows one out of many descriptions of the Document instance being printed. Sample Input 0 essay classes ['essay'] = essay essay_draft Document ("Violets are blue") classes ['essay_draft'] = essay_draft essay.append_content (essay_draft) essay.key = 0 exit Sample Output 0 Valid command Valid command Valid command Valid command Valid command Document ("Roses are red") Valid command This Document instance has the following stats. 1. word count: 6 2. status: draft 3. grade: awaiting submission 4. number of times the grade was requested before the document was submitted: 0 Sample Input 1 essay Document ("Roses are red"). classes ['essay'] = essay essay_draft classes ['essay_draft'] = essay_draft exit essay.append_content (essay_draft) another essay_v2 = Document ("Go away Anna! Okay bye.") essay.copy_content (another_essay_v2) essay.key=0 Document ("Violets are blue") Sample Output 1 Valid command Valid command Valid command Valid command Valid command Valid command Valid command Valid command This Document instance has the following stats. 1. word count: 5 2. status: draft 3. grade: awaiting submission 4. number of times the grade was requested before the document was submitted: 0 Sample Input 2 essay Document ("Roses are red") classes ['essay'] = essay essay_draft classes ['essay_draft'] = essay_draft Document ("Violets are blue") essay.append_content (essay_draft) essay.add_words ("Sugar is sweet and so are you") essay.key_1 essay.delete() essay.key = 0 exit Sample Output 2 Valid command. Valid command Valid command Valid command Valid command Valid command Invalid command Invalid command Valid command This Document instance has the following stats. 1. word count: 13. 2. status: draft 3. grade: awaiting submission 4. number of times the grade was requested before the document was submitted: 0 Sample Input 3 Document ("Roses are red"). essay classes ['essay'] = essay essay_draft Document ("Violets are blue"). classes ['essay_draft'] = essay_draft essay.append_content (essay_draft).append_content (essay_draft) essay.add_words ("Sugar is sweet and so are you") essay.key_1 essay.delete() essay.key=0 exit Sample Output 3 Valid command Valid command Valid command Valid command Valid command Valid command Invalid command Invalid command Valid command This Document instance has the following stats. 1. word count: 16 2. status: draft 3. grade: awaiting submission 4. number of times the grade was requested before the document was submitted: 0
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY