← 返回题库
中级

检测极端天气数据异常

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd, json
    payloads_csv = open_url(____).read()
    payloads = pd.read_csv(StringIO(____))
    EXTREME_LIMITS = {'____':____,'____':____,'____':____}
    def check_extreme_weather(____):
        try: p = json.loads(____)
        except: return []
        faults = []
        for metric, limit in EXTREME_LIMITS.items():
            val = p.get(____)
            if val is not None and abs(____) > limit:
                faults.append(metric + "____" + str(____) + "____" + str(____))
        return faults
    test_cases = [
        '____',
        '____',
        '____',
        '____',
    ]
    for tc in test_cases:
        faults = check_extreme_weather(____)
        print("____" if not faults else "____" + str(____))

示例

输入
solve()
期望输出
FAULT: ['wind_speed=55.0 exceeds_sensor_limit=50']
FAULT: ['air_temp=65.0 exceeds_sensor_limit=60']
FAULT: ['rainfall=150.0 exceeds_sensor_limit=100']
OK
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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