我正在为编程课程制作一个基本计算器,并且我已经阅读了 PDF,但我不知道如何制作一个函数,然后用它来打印两个数字相加的结果。有人可以帮我吗?
def addition(intFirstOperand, intSecondOperand):
addition = intFirstOperand + intSecondOperand
print ('What mathematical operation would you like to perform? Enter a number:')
print ('1 - addition')
print ('2 - subtraction')
print ('3 - multiplication')
print ('4 - division')
intOperation = input()
intOperation = int(intOperation)
addition = '1'
subtraction = '2'
multiplication = '3'
division = '4'
if intOperation == 1 :
print ('Please enter the first operand for addition:')
intFirstOperand = input()
print ('Please enter the second operand for addition:')
intSecondOperand = input()
print addition(intFirstOperand, intSecondOperand)
if intOperation == 2 :
print ('Please enter the first operand for subtractiom:')
intFirstOperand = input()
print ('Please enter the second operand for subtraction:')
intSecondOperand = input()
if intOperation == 3 :
print ('Please enter the first operand for multiplication:')
intFirstOperand = input()
print ('Please enter the second operand for multiplication:')
intSecondOperand = input()
if intOperation == 4 :
print ('Please enter the first operand for division:')
intFirstOperand = input()
print ('Please enter the second operand for division:')
intSecondOperand = input()