2016-09-12 2 views
0

мне нужно вычесть линии 5 от линии 4 и если отрицательный Введите 0, и это продолжает придумыватьвычитая две строки кода

def main(): 
    print("IRS Form 1040EZ Tax Computation Program (2015)") 
    print() 
    sal = eval(input("Line 1: Enter wages, salaries, and tips: ")) 
    tint = eval(input("Line 2: Enter taxable interest: ")) 
    print() 
    agros = print("Line 4: Adjusted Gross Income: ",sal + tint) 
    print() 
    exempt = eval(input("Line 5: Exemption Amount $ ")) 
    print("Line 6: Taxable Income: $",agros - exempt) 

main() 

IRS Form 1040EZ Tax Computation Program (2015) 

Line 1: Enter wages, salaries, and tips: 27500.00 
Line 2: Enter taxable interest: 250.00 

Line 4: Adjusted Gross Income: 27750.0 

Line 5: Exemption Amount $ 10150 

Traceback (most recent call last): 
    line 22, in main 
    print("Line 6: Taxable Income: $",agros - exempt) 
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' 

ответ

2

В строке

agros = print("Line 4: Adjusted Gross Income: ",sal + tint) 

Вы назначаете agros результат вызова print:

>>> a = print("") 
>>> print(a) 
None 

Вам нужно выполнить задание и печать отдельно:

agros = sal + tint 
print("Line 4: Adjusted Gross Income: ", agros) 
1

Не совсем питон парень, но я хотел бы попробовать:

agros = sal + tint 
print("Line 4: Adjusted Gross Income: ", agros) 
Смежные вопросы