1 Star 0 Fork 0

顶级魔法师 / pythonProject3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jisuanqi.py 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
顶级魔法师 提交于 2022-04-03 06:34 . jisuanqi
flag = True
while flag == True:
choice = input("请问你想用什么类型的计算器:0为普通计算器;1为复数计算器\n")
op = input("请选择一个运算符(复数只能选择1,2,3,4)\n1:加法\n2:减法\n3:乘法\n4:除法\n5:开几次方\n6:几次方\n")
if op == '0':
break
if choice == '1':
a= complex(input("请输入第一个复数\n"))
b = complex(input("请输入第二个复数\n"))
if choice == '0':
a = int(input("请输入第一个数:\n"))
b = int(input("请输入第二个数:\n"))
result = 0
if op == '4':
result = a / b
op='/'
elif op == '1':
result = a + b
op = '+'
elif op == '2':
result = a - b
op = '-'
elif op == '3':
result = a * b
op = '*'
elif op =='5':
result =a**(1/b)
op = '#'
elif op == '6':
result = pow(a, b)
op = '^'
else:
print('错了')
continue
if choice=='1':
print(str(a) + op + str(b), "=", result, "\n")
elif choice =='0':
print(str(a) + op + str(b), "=", result, "\n")
1
https://gitee.com/top-magician/pythonProject3.git
git@gitee.com:top-magician/pythonProject3.git
top-magician
pythonProject3
pythonProject3
master

搜索帮助