← 返回题库
中级

实现CPU持续过热告警检测

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    hb_csv = open_url(____).read()
    hb = pd.read_csv(StringIO(____))
    THRESHOLD = ____; CONSEC = ____
    def check(____):
        rows = df[df['____']==sid].sort_values(____)
        temps = list(____)
        max_c = ____; cur = ____
        for t in temps:
            cur = cur+____ if t > THRESHOLD else ____
            max_c = max(____)
        return max_c >= CONSEC, max_c, max(____) if temps else ____
    alerts = []
    for sid in list(hb['____'].unique())[:____]:
        is_alert, max_c, max_t = check(____)
        if is_alert:
            alerts.append({'____':sid,'____':max_c,'____':round(____)})
    print("____"+str(____)+"____"+str(____)+"____")
    for a in alerts[:____]:
        print("____"+a['____']+"____"+str(____)+"____"+str(____)+"____")
    print("____"+str(len(____)))

示例

输入
solve()
期望输出
Overheat alerts (>75.0C for 3 consecutive):
Total: 0
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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