ghaffarmumtat123 commited on
Commit
09bb6e9
·
verified ·
1 Parent(s): 0f09c68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -13,9 +13,16 @@ def solve_equation(equation):
13
  lhs_expr = sp.sympify(lhs)
14
  rhs_expr = sp.sympify(rhs)
15
  solution = sp.solve(lhs_expr - rhs_expr)
16
- return pd.DataFrame([["Solution", solution]], columns=["Equation", "Solution"])
 
 
 
 
 
 
 
17
  except Exception as e:
18
- return pd.DataFrame([["Error", str(e)]], columns=["Equation", "Error"])
19
 
20
  # Function to simplify expressions
21
  def simplify_expression(expression):
 
13
  lhs_expr = sp.sympify(lhs)
14
  rhs_expr = sp.sympify(rhs)
15
  solution = sp.solve(lhs_expr - rhs_expr)
16
+
17
+ # Ensure the solution is in a format suitable for the table (convert to string)
18
+ if isinstance(solution, list): # If the solution is a list of values
19
+ solution = ', '.join(map(str, solution)) # Convert the list to a string
20
+ else:
21
+ solution = str(solution) # Convert any other solution (single value) to string
22
+
23
+ return pd.DataFrame([["Equation", equation], ["Solution", solution]], columns=["Description", "Result"])
24
  except Exception as e:
25
+ return pd.DataFrame([["Error", str(e)]], columns=["Description", "Error"])
26
 
27
  # Function to simplify expressions
28
  def simplify_expression(expression):