Skip to content

Commit 28905b8

Browse files
committed
Update
1 parent 61524bb commit 28905b8

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Diff for: src/Equation_Plotter.py

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Version: 0.1.0
2+
Version: 0.1.1
33
Author: Minemetero
44
"""
55
import numpy as np
@@ -57,26 +57,32 @@ def get_range(prompt):
5757
def main():
5858
print("Welcome to the Equation Plotter!")
5959

60-
# Input equation from user
6160
while True:
62-
user_equation = input("Enter the equation in terms of 'x' (e.g., x**2 + 2*x + 1): ")
61+
# Input equation from user
62+
user_equation = input("Enter the equation in terms of 'x' (e.g., x**2 + 2*x + 1), or 'q' to quit: ")
63+
64+
if user_equation.lower() in ['q', 'quit']:
65+
print("Goodbye!")
66+
break
67+
6368
try:
6469
# Test if the equation can be evaluated
6570
x = np.linspace(-10, 10, 10)
6671
y = eval(user_equation)
6772
if isinstance(y, np.ndarray):
68-
break
73+
pass
6974
except Exception as e:
7075
print(f"Invalid equation: {e}")
71-
72-
# Get x range from user
73-
x_range = get_range("Enter the x range as two numbers separated by a comma (e.g., -10, 10): ")
74-
75-
# Get y range from user
76-
y_range = get_range("Enter the y range as two numbers separated by a comma (e.g., -10, 10): ")
77-
78-
# Plot the equation
79-
plot_equation(user_equation, x_range, y_range)
76+
continue
77+
78+
# Get x range from user
79+
x_range = get_range("Enter the x range as two numbers separated by a comma (e.g., -10, 10): ")
80+
81+
# Get y range from user
82+
y_range = get_range("Enter the y range as two numbers separated by a comma (e.g., -10, 10): ")
83+
84+
# Plot the equation
85+
plot_equation(user_equation, x_range, y_range)
8086

8187
if __name__ == "__main__":
8288
main()

0 commit comments

Comments
 (0)