两种写法各几行

👁️ 2 人浏览 💬 0 人评论 ❤️ 添加收藏

数一数命令式那版和声明式那版各占几行:

imp = """picked = []
for a in A:
    if a >= LINE:
        picked.append(a)
res = []
for a in picked:
    res.append(a * 10)
total = 0
for a in res:
    total = total + a"""

dec = """total = sum(map(lambda a: a * 10, filter(lambda a: a >= LINE, A)))"""

print(str(len(imp.split(chr(10)))) + "/" + str(len(dec.split(chr(10)))))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论