初学python:简易计算器

来源:互联网 发布:oecd2013年税收数据 编辑:程序博客网 时间:2024/05/17 01:14
choice=1while choice!=0:    choice=int(input("请输入你的选择:1、相加,2、相减,3、相乘,4、相除,0、退出"))    a=int(input("请输入第一个整数:"))    b=int(input("请输入第二个整数:"))    if choice==1:        print("{}+{}={}".format(a,b,(a+b)))    elif choice==2:        print("{}-{}={}".format(a, b, (a - b)))    elif choice==3:        print("{}*{}={}".format(a, b, (a * b)))    elif choice==4:        print("{}/{}={}".format(a, b, (a / b)))    else:        print("你即将退出计算")        break