Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def tax_calculator(income, marital_status, assets):
|
| 4 |
+
tax_brackets = [(10, 0), (25, 8), (60, 12), (120, 20), (250, 30)]
|
| 5 |
+
total_deductible = sum(assets["Cost"])
|
| 6 |
+
taxable_income = income - total_deductible
|
| 7 |
+
|
| 8 |
+
total_tax = 0
|
| 9 |
+
for bracket, rate in tax_brackets:
|
| 10 |
+
if taxable_income > bracket:
|
| 11 |
+
total_tax += (taxable_income - bracket) * rate / 100
|
| 12 |
+
|
| 13 |
+
if marital_status == "Married":
|
| 14 |
+
total_tax *= 0.75
|
| 15 |
+
elif marital_status == "Divorced":
|
| 16 |
+
total_tax *= 0.8
|
| 17 |
+
|
| 18 |
+
return round(total_tax)
|
| 19 |
+
|
| 20 |
+
demo = gr.Interface(
|
| 21 |
+
tax_calculator,
|
| 22 |
+
[
|
| 23 |
+
"number",
|
| 24 |
+
gr.Radio(["Single", "Married", "Divorced"]),
|
| 25 |
+
gr.Dataframe(
|
| 26 |
+
headers=["Item", "Cost"],
|
| 27 |
+
datatype=["str", "number"],
|
| 28 |
+
label="Assets Purchased this Year",
|
| 29 |
+
),
|
| 30 |
+
],
|
| 31 |
+
"number",
|
| 32 |
+
examples=[
|
| 33 |
+
[10000, "Married", [["Home", 6000], ["MacBook", 800], ["Car", 1800]]],
|
| 34 |
+
[80000, "Single", [["Fridge", 900], ["Watch", 3500], ["Furniture", 800]]],
|
| 35 |
+
],
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
demo.launch()
|