Mind+计算器
def hello():print('欢迎使用本计算器!')
while True:
select = int(input('请输入要操作的选项:1加法 2减法 3乘法 4除法'))
if select == 1:
add()
elif select == 2:
red()
elif select == 3:
rid()
elif select == 4:
exc()
else:
print('你的输入有误,请重新输入!!!')
continue
choice = input('是否继续?继续输入y,输入任意键退出.')
if choice != 'y':
break
def add():
a = float(input('请输入第一个加数:'))
b = float(input('请输入第二个加数:'))
result = a + b
print('两个数的和为{}'.format(result))
def red():
a = float(input('请输入被减数:'))
b = float(input('请输入减数:'))
result = a - b
print('两个数的差为{}'.format(result))
def rid():
a = float(input('请输入第一个因数:'))
b = float(input('请输入第二个因数:'))
result = a * b
print('两个数的积为{}'.format(result))
def exc():
a = float(input('请输入被除数:'))
b = float(input('请输入除数:'))
result = a / b
print('两个数的商为{}'.format(result))
hello()
不错不错 刚好在学Python,感谢分享! 赞赞赞赞赞 函数,不错
页:
[1]