sohaib7329 commited on
Commit
0aaa515
·
verified ·
1 Parent(s): 4a7b98c

Create app.pyp

Browse files
Files changed (1) hide show
  1. app.pyp +29 -0
app.pyp ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def temperature_converter(celsius, scale):
4
+ """Convert temperature from Celsius to the selected scale."""
5
+ if scale == "Kelvin":
6
+ return f"{celsius + 273.15} K"
7
+ elif scale == "Fahrenheit":
8
+ return f"{(celsius * 9/5) + 32} °F"
9
+ elif scale == "Rankine":
10
+ return f"{(celsius + 273.15) * 9/5} R"
11
+ else:
12
+ return "Invalid scale selected."
13
+
14
+ # Gradio Interface
15
+ description = "Enter a temperature in Celsius and select the desired scale to convert it into."
16
+
17
+ app = gr.Interface(
18
+ fn=temperature_converter,
19
+ inputs=[
20
+ gr.Number(label="Temperature in Celsius"),
21
+ gr.Radio(["Kelvin", "Fahrenheit", "Rankine"], label="Select Scale")
22
+ ],
23
+ outputs=gr.Textbox(label="Converted Temperature"),
24
+ title="Temperature Converter",
25
+ description=description
26
+ )
27
+
28
+ if __name__ == "__main__":
29
+ app.launch()