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("输入错误,请重新输入")