1
raw_input을 사용하여 아래 프로그램이 a, b, c 및 d에 대한 입력을 받아들이도록하십시오. 아래 프로그램을 수정하여 a, b, c 및 d에 대한 입력을 허용하십시오.raw_input을 사용하여 함수 값을 받아들입니다.
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
입니다 내가 이런 짓을 내가 구문 error.I 다른 모든 기능과 유사했다 얻었다.
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?"
나는 여기에 코멘트에 내 코드를 추가해야합니까? –
질문을 자세히 편집하려면 질문을 편집 할 수 있습니다. –
위의 코드를 추가했습니다. –