我希望下面的程序使用 raw_input 接受 a、b、c 和 d 的输入。请修改下面的程序以接受 a、b、c 和 d 的输入我试过这样做
def add(a, b)
print "Enter the values of a and b"
a = int(raw_input())
b = int(raw_input())
print return a + b
追溯是
File "a.py", line 5
return a + b)
^
SyntaxError: invalid syntax
我这样做了,我得到了语法错误。我对所有其他函数都做了类似的事情。
def add(a, b):
print "ADDING %d + %d" %(a, b)
return a + b
def subtract(a, b):
print "subtract %d - %d" %(a, b)
return a - b
def multiply(a, b):
print "multiply %d * %d" %(a, b)
return a * b
def divide(a, b):
print "divide %d + %d" %(a, b)
return a / b
print "Let's do some math with just functions!"
age = add(30, 5)
height = subtract(78, 5)
weight = multiply(90, 2)
iq = divide(100, 2)
print "Age: %d, Height: %d, Weight: %d, IQ: %d" % (age, height, weight, iq)
print "Here is a puzzle"
what = add(age, subtract(height, multiply(weight, divide(iq, 2))))
print "That is:", what, "How about that?"