关于python的一道题,急用
1个回答
展开全部
#!/usr/bin/env python3.6
salary_levels = [1500, 4500, 9000, 35000, 55000, 80000]
rate_levels = [0.03, 0.10, 0.2, 0.25, 0.3, 0.35, 0.45]
sub_levels = [0, 105, 555, 1005, 2755, 5505, 13505]
def get_level(salary, levels):
for i, s in enumerate(levels):
if salary <= s:
return i
return len(levels)
def get_tax(salary, rate, sub):
return (salary-3500) * rate - sub
def main():
salary = float(input('Enter the salary: '))
level = get_level(salary, salary_levels)
tax = get_tax(salary, rate_levels[level], sub_levels[level])
print(f'Income tax: {tax}')
if __name__ == '__main__':
main()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询