visitor pattern import abc import random import unittest class visitable(object)def accept(selfvisitor)visitor visit(selfclass compositevisitable(visitable)def __init__(selfiterable)self iterable iterable def accept(selfvisitor)for element in self iterableelement accept(visitorvisitor visit(selfclass abstractvisitor(object)__metaclass__ abc abcmeta @abc abstractmethod def visit(selfelement)raise notimplementederror(" visitor need to define visit method"class light(visitable)def __init__(selfname)self name name self status self get_status(def get_status(self)return random choice(range(- , )def is_online(self)return self status !- def boot_up(self)self status