Skip to content

Instantly share code, notes, and snippets.

@YoshiRi
Created March 19, 2022 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoshiRi/ee7712e3ee95291f23affd1330f72ffd to your computer and use it in GitHub Desktop.
Save YoshiRi/ee7712e3ee95291f23affd1330f72ffd to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# 年収から所得税を計算する
import numpy as np
import sys
# bollowed from : https://qiita.com/hideorder/items/a878a794418ef99b7f19
def CalcTax(income):
assert income > 0 , print("所得が控除額に届いていません")
p = [0.05, 0.10, 0.20, 0.23 ,0.33 , 0.40, 0.45]
bin = [i*10000 for i in [0, 195, 330, 695, 900, 1800, 4000, np.inf]]
deduction = [0, 97500, 427500, 636000, 1536000, 2796000, 4976000]
SpecialTax = 0.021
step = len(p)
ans = 0
i = 0
for i in range(step):
if (income >= bin[i]) and (income < bin[i+1]):
# 復興特別所得税有無
ans1 = (income*p[i] - deduction[i]) * (1 + SpecialTax)
ans2 = (income*p[i] - deduction[i]) * (1)
break
return ans1, ans2
if __name__=='__main__':
print('年収を入力してください[万円]')
income_manyen = float(input())
income_yen = income_manyen * 10000
print('経費を入力してください[万円]')
expenses_manyen = float(input())
expenses_yen = expenses_manyen * 10000
# 所得控除
kouzyo = 120 * 10000
syotoku = income_yen - expenses_yen - kouzyo
tax, _ = CalcTax(syotoku)
print("税金: ", tax)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment