马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
main.py代码from MyAlgorithmPackage.MyCalculator import MyOperator
# import MyCalculatorProject.operator as operator
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
while True:
'''
Add 加 +
ReductionOf 减 -
Take 乘 *
InAdditionTo 除 /
Aliquot 整除 //
ForMoreThan 求余 %
'''
if InputOperator == '+':
MyOperator.Add(InputNumberOne, InputNumberTwo)
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
elif InputOperator == '-':
MyOperator.ReductionOf(InputNumberOne, InputNumberTwo)
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
elif InputOperator == '*':
MyOperator.Take(InputNumberOne, InputNumberTwo)
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
elif InputOperator == '/':
MyOperator.InAdditionTo(InputNumberOne, InputNumberTwo)
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
elif InputOperator == '//':
MyOperator.Aliquot(InputNumberOne, InputNumberTwo)
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
elif InputOperator == '%':
MyOperator.ForMoreThan(InputNumberOne, InputNumberTwo)
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
else:
print('输入有误,请重新输入。')
IpublicBoolKeepRunning = str(input('是否继续(y/n):'))
if IpublicBoolKeepRunning == 'y':
InputNumberOne = int(input('请输入第一个数字:'))
InputOperator = str(input('输入运算符(+ - * / // %):'))
InputNumberTwo = int(input('请输入第二个数字:'))
else:
exit()
MyOperator.py代码def Add(NumberOne, NumberTwo):
print(NumberOne + NumberTwo)
def ReductionOf(NumberOne, NumberTwo):
print(NumberOne - NumberTwo)
def Take(NumberOne, NumberTwo):
print(NumberOne * NumberTwo)
def InAdditionTo(NumberOne, NumberTwo):
print(NumberOne / NumberTwo)
def Aliquot(NumberOne, NumberTwo):
print(NumberOne // NumberTwo)
def ForMoreThan(NumberOne, NumberTwo):
print(NumberOne % NumberTwo)
|