는 : 무엇을는 init 함수 파이썬의 내부 메소드를 호출이 코드에 문제가 있어요
이Traceback (most recent call last):
File "taxableincome.py", line 35, in <module>
main()
File "taxableincome.py", line 33, in main
salaryLister = Money(x)
File "taxableincome.py", line 7, in __init__
sal(self.salary)
NameError: global name 'sal' is not defined
: 전역 이름 '염'일
import math
class Money(object):
def __init__(self, salary):
self.salary = salary
sal(self.salary)
def sal(self, x):
y = (x - (((x * 0.22) + 6534)) - (1900.9408 + ((x - 37568)*.077)))
print '-----------------------------------------------------------'
print 'monthly income before tax will be: ${0:.2f}' .format(x/12)
print 'bi-weekly income before tax will be: ${0:.2f}' .format(x/24)
print 'Hourly after tax: ${0:.2f}' .format(x/24/70)
print '-----------------------------------------------------------'
print 'Income after tax will be: ${0:.2f}' .format(y)
print 'Monthly after tax: ${0:.2f}' .format((y/12))
print 'bi-weekly after tax: ${0:.2f}' .format((y/24))
print 'Hourly after tax: ${0:.2f}' .format(y/24/70)
answer = raw_input('Do you want to do this again?\nType [Y] or [N]: ')
if(answer == 'Y'):
sal(x)
else:
print 'Thank you!'
return
def main():
x = input('Enter your taxable income: ')
salaryLister = Money(x)
main()
역 추적이 보여 정의되지 않았습니까?
제 디자인에 대한 의견을 언제든지 보내주십시오. 나는 배우고 싶다. 당신이 파이썬에서 클래스의 인스턴스 메소드를 호출하는 방법을