Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import sympy as sp
|
|
| 4 |
# Function to solve algebraic equations
|
| 5 |
def solve_equation(equation):
|
| 6 |
try:
|
|
|
|
| 7 |
if "=" not in equation:
|
| 8 |
return "Invalid input. Please enter an equation with '=' (e.g., 2*x + 3 = 5)."
|
| 9 |
|
|
@@ -21,7 +22,9 @@ def solve_equation(equation):
|
|
| 21 |
# Function to simplify expressions
|
| 22 |
def simplify_expression(expression):
|
| 23 |
try:
|
|
|
|
| 24 |
expression = expression.replace("^", "**")
|
|
|
|
| 25 |
expr = sp.sympify(expression)
|
| 26 |
simplified_expr = sp.simplify(expr)
|
| 27 |
return f"Simplified Expression: {simplified_expr}"
|
|
@@ -31,7 +34,9 @@ def simplify_expression(expression):
|
|
| 31 |
# Function to factor expressions
|
| 32 |
def factor_expression(expression):
|
| 33 |
try:
|
|
|
|
| 34 |
expression = expression.replace("^", "**")
|
|
|
|
| 35 |
expr = sp.sympify(expression)
|
| 36 |
factored_expr = sp.factor(expr)
|
| 37 |
return f"Factored Expression: {factored_expr}"
|
|
@@ -123,8 +128,3 @@ def main():
|
|
| 123 |
# Run the app
|
| 124 |
if __name__ == "__main__":
|
| 125 |
main()
|
| 126 |
-
python -m venv venv
|
| 127 |
-
source venv/bin/activate # For macOS/Linux
|
| 128 |
-
venv\Scripts\activate # For Windows
|
| 129 |
-
pip install streamlit sympy
|
| 130 |
-
pip freeze > requirements.txt
|
|
|
|
| 4 |
# Function to solve algebraic equations
|
| 5 |
def solve_equation(equation):
|
| 6 |
try:
|
| 7 |
+
# Check if the equation contains "="
|
| 8 |
if "=" not in equation:
|
| 9 |
return "Invalid input. Please enter an equation with '=' (e.g., 2*x + 3 = 5)."
|
| 10 |
|
|
|
|
| 22 |
# Function to simplify expressions
|
| 23 |
def simplify_expression(expression):
|
| 24 |
try:
|
| 25 |
+
# Replace '^' with '**' for exponentiation
|
| 26 |
expression = expression.replace("^", "**")
|
| 27 |
+
|
| 28 |
expr = sp.sympify(expression)
|
| 29 |
simplified_expr = sp.simplify(expr)
|
| 30 |
return f"Simplified Expression: {simplified_expr}"
|
|
|
|
| 34 |
# Function to factor expressions
|
| 35 |
def factor_expression(expression):
|
| 36 |
try:
|
| 37 |
+
# Replace '^' with '**' for exponentiation
|
| 38 |
expression = expression.replace("^", "**")
|
| 39 |
+
|
| 40 |
expr = sp.sympify(expression)
|
| 41 |
factored_expr = sp.factor(expr)
|
| 42 |
return f"Factored Expression: {factored_expr}"
|
|
|
|
| 128 |
# Run the app
|
| 129 |
if __name__ == "__main__":
|
| 130 |
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|