← 返回题库
中级

实现高温告警与通风联动控制

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd, json
    devs_csv = open_url(____).read()
    devs = pd.read_csv(StringIO(____))
    ALERT_HIGH = ____
    CLOSE_TEMP = ____
    vent_state = {}
    def process_temp(____):
        current_open = vent_state.get(____)
        if air_temp > ALERT_HIGH and not current_open:
            vent_state[zone] = True
            return '____', {'____':'____','____':air_temp,'____':'____','____':zone}
        elif air_temp <= CLOSE_TEMP and current_open:
            vent_state[zone] = False
            return '____', {'____':'____','____':zone,'____':air_temp}
        return '____', {'____':air_temp,'____':current_open}
    readings = [
        (____),(____),(____),
        (____),(____),
    ]
    print(____)
    for zone, temp, ts in readings:
        action, info = process_temp(____)
        print("____"+str(____)+"____"+str(____)+"____"+action+"____"+str(____))

示例

输入
solve()
期望输出
High-temp alert + vent linkage:
  ts=1748736000 temp=26.5C: MONITOR {'temp': 26.5, 'vent_open': False}
  ts=1748736300 temp=29.0C: MONITOR {'temp': 29.0, 'vent_open': False}
  ts=1748736600 temp=33.5C: ALERT+COMMAND {'type': 'high_temp', 'temp': 33.5, 'cmd': 'open_vent', 'zone': 'A区'}
  ts=1748736900 temp=31.0C: MONITOR {'temp': 31.0, 'vent_open': True}
  ts=1748737200 temp=27.5C: COMMAND {'cmd': 'close_vent', 'zone': 'A区', 'temp': 27.5}
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码