1.计算器
def add(a,b):
if a.isdigit() and b.isdigit():
s=int(a)+int(b);
print("相加为%s"%s);
else:
print("请输入数字")
def reduce(a,b):
if a.isdigit() and b.isdigit():
s=int(a)-int(b);
print("相减为%s"%s);
else:
print("请输入数字")
def ride(a,b):
if a.isdigit() and b.isdigit():
s=int(a)*int(b);
print("相乘为%s"%s);
else:
print("请输入数字")
def excep(a,b):
if a.isdigit() and b.isdigit():
s=int(a)/int(b);
print("相除为%.2f"%s);
else:
print("请输入数字")
while True:
h=input("1.加 2.减 3.乘 4.除")
one = input("请输入第一个数字")
two = input("请输入第二个数字")
if h=="1":
add(one,two)
elif h=="2":
reduce(one,two)
elif h=="3":
ride(one,two)
elif h=="4":
excep(one,two)