用户:宋怡芃查看:1 回复:7 评论:1 创建时间:2022-02-01T10:55:20
【作品展示】

【作品介绍】
新年快乐,宋氏计算器有更新了,快来体验吧
【作品源代码】
try:
print(('注意啦,下面要用这条提示:1=加法 2=减法 3=乘法 4=除法'))
a = int(input('您需要的运算方法:'))
b = int(input('请输入第一个数:'))
c = int(input('请输入第二个数:'))
if a != (1, 4):
print('运算方法有误')
if a == 1:
d = (b + c)
print(d)
print(round(d))
if a == 2:
e = (b - c)
print(e)
print(round(e))
if a == 3:
f = (b * c)
print(f)
print(round(f))
if a == 4:
g = (b / c)
print(g)
print(round(g))
except:
print('请输入数字')
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
一门鸽鸽1.try expect语句的expect部分最好加上错误类型,否则他会接受任何错误
2.a != (1,4)这一句永远不会成立,你妄想让int类型等于tuple类型
正确写法:a not in range(1,5)
点赞1
评论