prathamt commited on
Commit
7dd00f2
·
verified ·
1 Parent(s): b336eab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -47,6 +47,11 @@ class Quadratic:
47
  # -------- Function for Gradio --------
48
  def solve_and_plot(a, b, c):
49
  try:
 
 
 
 
 
50
  quad = Quadratic(a, b, c)
51
  root1, root2 = quad.solveQuad()
52
  fig = quad.drawFigure()
@@ -69,7 +74,7 @@ theme = gr.themes.Soft(
69
  secondary_hue="blue",
70
  neutral_hue="slate",
71
  font=[
72
- gr.themes.GoogleFont("Inter"), # You can change to Poppins, Roboto, etc.
73
  "ui-sans-serif",
74
  "system-ui"
75
  ]
@@ -80,9 +85,9 @@ theme = gr.themes.Soft(
80
  interface = gr.Interface(
81
  fn=solve_and_plot,
82
  inputs=[
83
- gr.Number(label="Coefficient a"),
84
- gr.Number(label="Coefficient b"),
85
- gr.Number(label="Coefficient c"),
86
  ],
87
  outputs=[
88
  gr.Textbox(label="Solution"),
 
47
  # -------- Function for Gradio --------
48
  def solve_and_plot(a, b, c):
49
  try:
50
+ # Convert string inputs to float (supports negative values)
51
+ a = float(a)
52
+ b = float(b)
53
+ c = float(c)
54
+
55
  quad = Quadratic(a, b, c)
56
  root1, root2 = quad.solveQuad()
57
  fig = quad.drawFigure()
 
74
  secondary_hue="blue",
75
  neutral_hue="slate",
76
  font=[
77
+ gr.themes.GoogleFont("Inter"),
78
  "ui-sans-serif",
79
  "system-ui"
80
  ]
 
85
  interface = gr.Interface(
86
  fn=solve_and_plot,
87
  inputs=[
88
+ gr.Textbox(label="Coefficient a", value="1"),
89
+ gr.Textbox(label="Coefficient b", value="0"),
90
+ gr.Textbox(label="Coefficient c", value="0"),
91
  ],
92
  outputs=[
93
  gr.Textbox(label="Solution"),