Spaces:
Sleeping
Sleeping
import gradio as gr | |
# Function to solve for x using cross-multiplication | |
def solve_cross_multiplication(a, b, c, d): | |
# We have a/b = c/x => x = (b*c)/a | |
try: | |
x = (b * d) / a | |
return x | |
except ZeroDivisionError: | |
return "Division by zero error" | |
# Gradio interface | |
def interface(a, b, c, d): | |
result = solve_cross_multiplication(a, b, c, d) | |
return result | |
inputs = [ | |
gr.Number(label="a (Numerator 1)"), | |
gr.Number(label="b (Denominator 1)"), | |
gr.Number(label="c (Numerator 2)"), | |
gr.Number(label="d (Denominator 2)") | |
] | |
outputs = gr.Textbox(label="x (Result)") | |
gr.Interface(fn=interface, inputs=inputs, outputs=outputs, title="Cross Multiplication Solver").launch() | |