Spaces:
Runtime error
Runtime error
File size: 533 Bytes
9b3b8c8 291349f 9b3b8c8 291349f db31576 291349f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from typing import Union
import gradio as gr
def divide(a: float, b: float) -> Union[float, str]:
"""Divide a by b."""
try:
a, b = float(a), float(b)
if b == 0:
return "Error: Division by zero"
return a / b
except (ValueError, TypeError):
return "Error: Both inputs must be valid numbers"
divide_interface = gr.Interface(
fn=divide,
inputs=[gr.Number(label="A"), gr.Number(label="B")],
outputs="text",
title="Division",
description="Divide two numbers"
)
|