samimohammeds/AccountStatements
0
1import gradio as gr2 3class Bank_Account:4 def __init__(self):5 self.balance = 06 7 def deposit(self, amount):8 self.balance += amount9 return f"Amount Deposited: ₹{amount}", self.balance10 11 def withdraw(self, amount):12 if self.balance >= amount:13 self.balance -= amount14 return f"Amount Withdrawn: ₹{amount}", self.balance15 else:16 return "Insufficient balance", self.balance17 18 def display(self):19 return f"Net Available Balance: ₹{self.balance}"20 21# Create bank account instance22account = Bank_Account()23 24# Gradio interface functions25def deposit_fn(amount):26 return account.deposit(amount)27 28def withdraw_fn(amount):29 return account.withdraw(amount)30 31def balance_fn():32 return account.display()33 34# Gradio UI35with gr.Blocks() as demo:36 gr.Markdown("## 💰 Deposit & Withdrawal Machine")37 38 with gr.Row():39 deposit_input = gr.Number(label="Enter Deposit Amount")40 deposit_btn = gr.Button("Deposit")41 deposit_output = gr.Textbox(label="Deposit Status")42 deposit_balance = gr.Textbox(label="Balance After Deposit")43 44 deposit_btn.click(deposit_fn, inputs=deposit_input, outputs=[deposit_output, deposit_balance])45 46 with gr.Row():47 withdraw_input = gr.Number(label="Enter Withdrawal Amount")48 withdraw_btn = gr.Button("Withdraw")49 withdraw_output = gr.Textbox(label="Withdrawal Status")50 withdraw_balance = gr.Textbox(label="Balance After Withdrawal")51 52 withdraw_btn.click(withdraw_fn, inputs=withdraw_input, outputs=[withdraw_output, withdraw_balance])53 54 with gr.Row():55 balance_btn = gr.Button("Check Balance")56 balance_output = gr.Textbox(label="Current Balance")57 58 balance_btn.click(balance_fn, outputs=balance_output)59 60# Launch the app61demo.launch()62 