Question (see pic)  Code: (see question below the code):  class Document:   #TO DO: define the constructor method, __init__ and then initialize values   #def __init__(___, ___):     # initilialize values here        #TO DO: define the method add_words   #def add_words(___, ___):      #TO DO: define the method submit   #def submit(___):      #TO DO: define the method get_grade   #def get_grade(___):      def __str__(self):     #TO DO: Fill in the blanks     document_info = f"This Document instance has _ instance attributes.\n"     document_info += f"The class used to create this object has _ methods and _ class attribute.\n"     document_info += f"This Document instance has the following stats.\n"     #TO DO: Complete document_info by adding more lines below            return document_info    if __name__ == "__main__":   while(True):     command = input()     if command == 'exit':       break     exec(command)   print(essay)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Question (see pic) 

Code: (see question below the code)

class Document:
  #TO DO: define the constructor method, __init__ and then initialize values
  #def __init__(___, ___):
    # initilialize values here
    

  #TO DO: define the method add_words
  #def add_words(___, ___):
  
  #TO DO: define the method submit
  #def submit(___):
  

  #TO DO: define the method get_grade
  #def get_grade(___):
  

  def __str__(self):
    #TO DO: Fill in the blanks
    document_info = f"This Document instance has _ instance attributes.\n"
    document_info += f"The class used to create this object has _ methods and _ class attribute.\n"
    document_info += f"This Document instance has the following stats.\n"
    #TO DO: Complete document_info by adding more lines below
      
    return document_info
  
if __name__ == "__main__":
  while(True):
    command = input()
    if command == 'exit':
      break
    exec(command)
  print(essay)

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,
(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:
str . For this exercise, we will add the following attribute/s:
(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.
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 2
essay = Document ("Roses are red")
classes ['essay'] = essay
essay_draft = Document ("Violets are blue")
classes ['essay_draft'] = essay_draft
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 Input 0
essay = Document ("Roses are red")
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
Sample Output 2
Valid command
Valid command
Valid command
Valid command
This Document instance has the following stats.
1. word count: 6
Valid command
Valid command
Valid command
2. status: draft
3. grade: awaiting submission
4. number of times the grade was requested before the document was submitted: 0
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 1
essay = Document ("Roses are red")
classes['essay'] = essay
essay_draft = Document("Violets are blue")
classes ['essay_draft'] = essay_draft
essay.append_content (essay_draft)
another_essay_v2 = Document ("Go away Anna! Okay bye.")
essay.copy_content(another_essay_v2)
essay.key = 0
Sample Input 3
essay = Document ("Roses are red")
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
exit
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
Sample Output 3
Valid command
Valid command
Valid command
Valid command
Valid command
2. status: draft
3. grade: awaiting submission
4. number of times the grade was requested before the document was submitted: 0
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, (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: str . For this exercise, we will add the following attribute/s: (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. 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 2 essay = Document ("Roses are red") classes ['essay'] = essay essay_draft = Document ("Violets are blue") classes ['essay_draft'] = essay_draft 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 Input 0 essay = Document ("Roses are red") 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 Sample Output 2 Valid command Valid command Valid command Valid command This Document instance has the following stats. 1. word count: 6 Valid command Valid command Valid command 2. status: draft 3. grade: awaiting submission 4. number of times the grade was requested before the document was submitted: 0 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 1 essay = Document ("Roses are red") classes['essay'] = essay essay_draft = Document("Violets are blue") classes ['essay_draft'] = essay_draft essay.append_content (essay_draft) another_essay_v2 = Document ("Go away Anna! Okay bye.") essay.copy_content(another_essay_v2) essay.key = 0 Sample Input 3 essay = Document ("Roses are red") 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 exit 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 Sample Output 3 Valid command Valid command Valid command Valid command Valid command 2. status: draft 3. grade: awaiting submission 4. number of times the grade was requested before the document was submitted: 0 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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education