Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def simple_calculator(num1, num2, operation): | |
| try: | |
| if operation == "+": | |
| result = num1 + num2 | |
| elif operation == "-": | |
| result = num1 - num2 | |
| elif operation == "*": | |
| result = num1 * num2 | |
| elif operation == "/": | |
| result = num1 / num2 if num2 != 0 else "β (Divide by Zero)" | |
| else: | |
| result = "Unknown operation" | |
| return f"β Result: {result}" | |
| except Exception as e: | |
| return f"β Error: {str(e)}" | |
| demo = gr.Interface( | |
| fn=simple_calculator, | |
| inputs=[ | |
| gr.Number(label="Enter First Number"), | |
| gr.Number(label="Enter Second Number"), | |
| gr.Radio(["+", "-", "*", "/"], label="Operation"), | |
| ], | |
| outputs="text", | |
| title="π§ AI Calculator", | |
| description="", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |