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

To create the program for keeping track of boxes in a doctor's office, I'll provide the responses step by step based on the prompts given.

  1. Create a class for box objects with three attributes: date, contents, and location.
class Box:
    def __init__(self, date, contents, location):
        self.date = date
        self.contents = contents
        self.location = location
  1. Create instances of the class for the specific boxes.
box_23 = Box('2016', 'medical records', 'storage closet')
box_21 = Box('2018', 'lotion samples', 'waiting room')
box_07 = Box('2020', 'flyers about the flu shot', 'receptionist desk')
  1. Print out the date of box #23, the contents of box #07, and the location of box #21.
print(box_23.date)
print(box_07.contents)
print(box_21.location)
  1. Write a method to tell if the attributes of two boxes are identical.
def are_boxes_identical(box1, box2):
    return (box1.date == box2.date and 
            box1.contents == box2.contents and 
            box1.location == box2.location)
  1. Create box #10 with identical attributes to Box #07, and write statements to compare boxes.
box_10 = Box('2020', 'flyers about the flu shot', 'receptionist desk')

# Compare the contents of Box #07 and Box #10
print(box_07.contents == box_10.contents)

# Compare the contents of Box #21 and Box #23
print(box_21.contents == box_23.contents)

Now, if you put each segment of code in the appropriate input boxes as per the prompts, you will complete your program for keeping track of boxes in a doctor's office!