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.
- 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
- 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')
- 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)
- 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)
- 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!