← 返回题库
中级

实现CPT计费模型计算

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    bc_csv = open_url(____).read()
    configs = pd.read_csv(StringIO(____))
    cpt = configs[configs['____']=='____']
    SLOTS = {'____':____,'____':____,'____':____,'____':____}
    def calc_cpt(____):
        cfg = cpt[cpt['____']==cfg_id]
        if cfg.empty or slot not in SLOTS: return None
        price = float(____)
        return {'____':slot,'____':days,'____':price,'____':round(____)}
    print(____)
    for slot, days, cfg_id in [(____),(____),(____)]:
        r = calc_cpt(____)
        if r: print("____"+r['____']+"____"+str(____)+"____"+str(____)+"____"+str(____)+"____")

示例

输入
solve()
期望输出
CPT billing:
  morning_peak days=30 price=500.0/day -> cost=15000.0 CNY
  noon days=14 price=200.0/day -> cost=2800.0 CNY
  evening_peak days=7 price=500.0/day -> cost=3500.0 CNY
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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