我需要将该等式变成9。下面是一个示例:
并且代码必须使用
乘数def add_numbers(a, b):
result = a + b
return result
def sub_numbers(a, b):
Write code to return sum of a and b
result = None #Replace None with your code
return result
有人可以帮我重写代码吗?
def add_numbers(5, 4):
result = 5 + 4
return result
def sub_numbers(5, 4):
# Write code to return sum of a and b
result = 5-4
return result
print(mult_numbers(add_numbers(5,4), sub_numbers(5,4)))
我正在接收:
def add_numbers(5, 4):
^
SyntaxError:语法无效
答案 0 :(得分:0)
您不能将数字写为函数参数,必须定义变量来保存参数,这是正确的代码:
def add_numbers(n1, n2):
result = n1 + n2
return result
def sub_numbers(n1, n2):
# Write code to return sum of a and b
result = n1-n2
return result
print(mult_numbers(add_numbers(5,4), sub_numbers(5,4)))