2014-04-24 4 views
-1

저는 초보자 인 Python을 배우며이 코드와 비슷한 코드를 실행하여 정상적으로 작동합니다. 그런 다음 몇 가지 변경 (하나의 곱하기 함수 대신 multiply_two 및 multiply_three 함수를 만들었습니다)을 실행하고 다시 실행했지만 total_hours_worked = float (... 및 그 아래 다른 두 개의 구문 오류 . 내가 뭘 잘못했는지 알아낼 수 없습니다 어떤 조언을 주시면 감사Python 2.7 구문 오류가 잘못되었습니다.

def multiply_two(a, b): 
    print "Multiplying %d and %d to get annual earnings." % (a, b) 
    return a * b 

def multiply_three(a, b, c): 
    print "Multiplying %d, %d, and %d to get total hours worked per year." % (a, b, c) 
    return a * b * c 

def add(a, b): 
    print "Adding %d and %d to get total annual compensation." % (a, b) 
    return a + b 

hours_worked = float(raw_input("How many hours per day do you work?\n> ")) 
days_worked = float(raw_input("How many days per week do you work?\n> ")) 
weeks_worked = float(raw_input("How many weeks per year do you work?\n> ")) 
wage = float(raw_input("What is your hourly wage?\n> ")) 
bonus = float(raw_input("What is your yearly bonus amount, in dollars?\n ") 

total_hours_worked = float(multiply_three(hours_worked, days_worked, weeks_worked)) 
annual_earnings = float(multiply_two(total_hours_worked, wage)) 
total_annual_compensation = float(add(annual_earnings, bonus)) 

print "\nYour total hours worked per year are %r." % total_hours_worked 
print "Your annual earnings are $%r." % annual_earnings 
print "Your total annual compensation is $%r." % total_annual_compensation 

답변

4

당신은 괄호를 놓쳤다 ")"줄의 끝에 :..

 
bonus = float(raw_input("What is your yearly bonus amount, in dollars?\n ") 
+0

감사합니다, 그것을 해결하는! 나는 그것을 알아 차리지 못했다. – pez

관련 문제