Created
July 12, 2023 10:08
-
-
Save juanluisrto/f55e8e68e96570b735642914788bc561 to your computer and use it in GitHub Desktop.
Función para estimar el irpf a pagar en España, teniendo en cuenta los tramos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculadora_impuestos(ingresos): | |
irpf_escalones = { | |
12_450 : 0.19, | |
20_200 : 0.24, | |
35_200 : 0.30, | |
60_000 : 0.37, | |
300_000 : 0.45, | |
1e100 : 0.47 | |
} | |
tramos = sorted(irpf_escalones) | |
impuestos = 0 | |
for t in tramos: | |
if t <= ingresos: | |
impuestos += t*irpf_escalones[t] | |
ingresos -= t | |
else: | |
impuestos += ingresos*irpf_escalones[t] | |
break | |
return impuestos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment