用户:Loki_XVI查看:0 回复:1 评论:0 创建时间:2022-11-18T17:31:26
【作品展示】

【作品介绍】
4位数之和
【作品源代码】
import math
num = eval(input("请输入一个四位数"))
a = math.floor(num / 1000)
b = math.floor((num % 1000) / 100)
c = math.floor((num % 100) / 10)
d = (num % 10)
newnum = (((a + b) + c) + d)
print('各数位之和为:', newnum)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn