← 返回题库
中级

生成收支对比月度报表

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    rpts=pd.read_csv(StringIO(open_url(____).read()))
    print(____)
    for _,r in rpts.head(____).iterrows():
        inc,exp,bal=float(____),float(____),float(____)
        rate=round((____)/inc*____,____) if inc>____ else ____
        print(____)

示例

输入
solve()
期望输出
Income vs expense:
  USR-0001 2026-01-01: income=7506.96 exp=2486.16 bal=2908.73 save=66.9% [surplus]
  USR-0001 2026-01-31: income=12066.26 exp=2486.16 bal=8104.09 save=79.4% [surplus]
  USR-0002 2026-01-01: income=10427.34 exp=1946.05 bal=7954.87 save=81.3% [surplus]
  USR-0002 2026-01-31: income=10667.02 exp=1946.05 bal=8490.16 save=81.8% [surplus]
  USR-0003 2026-01-01: income=8236.81 exp=2215.73 bal=7468.22 save=73.1% [surplus]
  USR-0003 2026-01-31: income=13676.62 exp=2215.73 bal=8771.07 save=83.8% [surplus]
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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