python-简单计算器实现
作者:互联网
python-简单计算器实现
1. 简单计算器实现
#!/usr/bin/env python3
# _*_ coding: utf-8 _*_
# Author:shichao
# File: .py
print("选择算术运算符")
print("1.加\n2.减\n3.乘\n4.除")
choice = input("请输入编号: ")
num1 = int(input("请输入第一个数字: "))
num2 = int(input("请输入第二个数字: "))
if choice == '1':
c = num1 + num2
print("相加结果为:%d" %c)
elif choice == '2':
c = num1 - num2
print("相减结果:%d" %c)
elif choice == '3':
c = num1 * num2
print(c)
elif choice == '4':
c = num1 / num2
print(c)
else:
print("输入错误,请重新输入")
标签:elif,num1,num2,python,计算器,choice,简单,print,input 来源: https://www.cnblogs.com/scajy/p/15847282.html