DGRDN commited on
Commit
af56c98
·
verified ·
1 Parent(s): ab8a584

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from sympy import symbols, Eq, solve
3
+
4
+ x, y = symbols('x y')
5
+
6
+ def solve_system(eq1_str, eq2_str):
7
+ try:
8
+ # Evaluate the equations safely
9
+ eq1 = eval(eq1_str)
10
+ eq2 = eval(eq2_str)
11
+ solution = solve((eq1, eq2), (x, y))
12
+ if not solution:
13
+ return "❌ No solution found. Check your equations."
14
+ return f"✅ Solution:\nx = {solution[x]}\ny = {solution[y]}"
15
+ except Exception as e:
16
+ return f"⚠️ Error: {str(e)}"
17
+
18
+ demo = gr.Interface(
19
+ fn=solve_system,
20
+ inputs=[
21
+ gr.Textbox(label="Equation 1 (e.g., Eq(2*x + 3*y, 12))"),
22
+ gr.Textbox(label="Equation 2 (e.g., Eq(x - y, 3))")
23
+ ],
24
+ outputs="text",
25
+ title="🧮 Two-Variable Algebra Solver",
26
+ description="Enter two equations using SymPy syntax. Example: Eq(2*x + 3*y, 12)"
27
+ )
28
+
29
+ demo.launch()