File size: 579 Bytes
9b3b8c8
 
 
fe0557b
 
9b3b8c8
 
 
 
 
 
fe0557b
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Solve the equation ax = b for x.
"""
import gradio as gr

def solve_linear_equation(a, b):
    if a == 0:
        if b == 0:
            return "Infinite solutions"
        return "No solution"
    return b / a

solve_linear_equation_interface = gr.Interface(
    fn=solve_linear_equation,
    inputs=[
        gr.Number(label="Coefficient (a)"),
        gr.Number(label="Constant (b)")
    ],
    outputs="text",
    title="Linear Equation Solver",
    description="Solve the equation ax = b for x"
)

if __name__ == "__main__":
    solve_linear_equation_interface.launch()