import gradio as gr import math def emi_calculator(principal, rate, time): try: principal = float(principal) rate = float(rate) time = float(time) if principal <= 0 or rate <= 0 or time <= 0: return "❌ Please enter positive values only." rate = rate / (12 * 100) time = time * 12 emi = (principal * rate * pow(1 + rate, time)) / (pow(1 + rate, time) - 1) return f"✅ Your Monthly EMI is: ₹{round(emi, 2)}" except: return "⚠️ Please enter valid numeric values." # 🌸 New background with soft blur-glass style card custom_css = """ body { background: linear-gradient(135deg, #fce4ec, #f8bbd0); background-attachment: fixed; font-family: 'Segoe UI', sans-serif; margin: 0; padding: 0; } h1, h3 { color: #ad1457; text-align: center; margin-top: 10px; } .gradio-container { padding: 2rem; } .card { background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(12px); border-radius: 16px; padding: 2rem; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05); max-width: 700px; margin: 0 auto; } textarea { background-color: #fff0f5 !important; border: 1px solid #f48fb1 !important; border-radius: 10px !important; } .gr-button { background-color: #ec407a !important; color: white !important; font-weight: bold !important; border-radius: 10px !important; padding: 0.75em 1.5em !important; } """ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="pink")) as demo: gr.Markdown("""

🌸 EMI Calculator 🌸

Enter your details to calculate your monthly loan payments 💸

""") with gr.Row(): principal = gr.Textbox(label="🏦 Loan Amount (₹)", placeholder="e.g., 500000") rate = gr.Textbox(label="📈 Annual Interest Rate (%)", placeholder="e.g., 7.5") time = gr.Textbox(label="⏳ Loan Duration (Years)", placeholder="e.g., 10") output = gr.Textbox(label="📄 Result", max_lines=1) gr.Button("Calculate EMI").click(fn=emi_calculator, inputs=[principal, rate, time], outputs=output) gr.Markdown("
") # closing .card demo.launch(share=True)