Use the prompts on the left to select the appropriate lines of code to create the program for keeping track of boxes in a doctor's office. (Hint: do NOT rely on the line numbers to the left of the code. If changes are made to classes or functions during later steps, that might alter the initial line numbers)(10 points) Put responses in the correct input to answer the question. Select a response, navigate to the desired input and insert the response. Responses can be selected and inserted using the space bar, enter key, left mouse button or touchpad. Responses can also be moved by dragging with a mouse. 1) You are designing a program that will keep track of the boxes in a doctor’s office. Each box will have three attributes: date, contents, and location. Write a class that will consist of box objects. 2) Continuing with the program in the first problem, create instances of the class for these boxes: Box #23 contains medical records from 2016 and is in the storage closet. Box #21 contains lotion samples manufactured in 2018 and is in the waiting room. Box #07 contains flyers about the flu shot for 2020 and is in the receptionist’s desk. 3) Continuing with the program in the second problem, write statements that will print out the date of box #23, the contents of box #07, and the location of box #21. 4) Continuing with the program in problem #3, write a method that could be used to tell if the attributes of two boxes are identical. 5) Continuing with the program in problem #4: Box #10 has identical attributes to Box #07. Create box #10. Then, write two statements that will print out: one will compare the contents of Box #07 and Box #10, and the other will compare the contents of Box #21 and Box #23.

1 answer

Here’s how you can create the program for keeping track of boxes in a doctor’s office, following your prompts step by step.

1) Defining the Box Class

class Box:
    def __init__(self, date, contents, location):
        self.date = date
        self.contents = contents
        self.location = location

2) Creating Instances of the Class

box_23 = Box("2016", "medical records", "storage closet")
box_21 = Box("2018", "lotion samples", "waiting room")
box_07 = Box("2020", "flyers about flu shot", "receptionist's desk")

3) Printing Attributes of Instances

print(box_23.date)  # Printing the date of box #23
print(box_07.contents)  # Printing the contents of box #07
print(box_21.location)  # Printing the location of box #21

4) Method to Check Identical Attributes

def are_identical(box1, box2):
    return (box1.date == box2.date and
            box1.contents == box2.contents and
            box1.location == box2.location)

5) Creating Box #10 and Comparing Attributes

box_10 = Box("2020", "flyers about flu shot", "receptionist's desk")  # Box #10 identical to Box #07

# Comparing contents of Box #07 and Box #10
print(are_identical(box_07, box_10))  # Should return True

# Comparing contents of Box #21 and Box #23
print(are_identical(box_21, box_23))  # Should return False

Complete Program

Combining all the steps, the complete code looks like this:

class Box:
    def __init__(self, date, contents, location):
        self.date = date
        self.contents = contents
        self.location = location

box_23 = Box("2016", "medical records", "storage closet")
box_21 = Box("2018", "lotion samples", "waiting room")
box_07 = Box("2020", "flyers about flu shot", "receptionist's desk")

print(box_23.date)  # Box #23 date
print(box_07.contents)  # Box #07 contents
print(box_21.location)  # Box #21 location

def are_identical(box1, box2):
    return (box1.date == box2.date and
            box1.contents == box2.contents and
            box1.location == box2.location)

box_10 = Box("2020", "flyers about flu shot", "receptionist's desk")  # Box #10 identical to Box #07

print(are_identical(box_07, box_10))  # Comparing Box #07 and Box #10
print(are_identical(box_21, box_23))  # Comparing Box #21 and Box #23

You can run this Python code to keep track of the boxes in a doctor's office as specified in the prompts.