CoderHassan commited on
Commit
510595a
·
verified ·
1 Parent(s): 67a13f3

Upload app (1).py

Browse files
Files changed (1) hide show
  1. app (1).py +41 -0
app (1).py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title and Description
4
+ st.title("Temperature Conversion App")
5
+ st.markdown("Convert temperatures between Celsius, Fahrenheit, and Kelvin.")
6
+
7
+ # Input Temperature
8
+ temp_input = st.number_input("Enter the temperature to convert:", format="%.2f")
9
+
10
+ # Conversion Option
11
+ conversion_type = st.radio(
12
+ "Select conversion type:",
13
+ (
14
+ "Celsius to Fahrenheit",
15
+ "Fahrenheit to Celsius",
16
+ "Celsius to Kelvin",
17
+ "Kelvin to Celsius",
18
+ "Fahrenheit to Kelvin",
19
+ "Kelvin to Fahrenheit",
20
+ ),
21
+ )
22
+
23
+ # Conversion Logic
24
+ if conversion_type == "Celsius to Fahrenheit":
25
+ converted_temp = (temp_input * 9/5) + 32
26
+ st.write(f"{temp_input:.2f}°C is equal to {converted_temp:.2f}°F.")
27
+ elif conversion_type == "Fahrenheit to Celsius":
28
+ converted_temp = (temp_input - 32) * 5/9
29
+ st.write(f"{temp_input:.2f}°F is equal to {converted_temp:.2f}°C.")
30
+ elif conversion_type == "Celsius to Kelvin":
31
+ converted_temp = temp_input + 273.15
32
+ st.write(f"{temp_input:.2f}°C is equal to {converted_temp:.2f} K.")
33
+ elif conversion_type == "Kelvin to Celsius":
34
+ converted_temp = temp_input - 273.15
35
+ st.write(f"{temp_input:.2f} K is equal to {converted_temp:.2f}°C.")
36
+ elif conversion_type == "Fahrenheit to Kelvin":
37
+ converted_temp = (temp_input - 32) * 5/9 + 273.15
38
+ st.write(f"{temp_input:.2f}°F is equal to {converted_temp:.2f} K.")
39
+ elif conversion_type == "Kelvin to Fahrenheit":
40
+ converted_temp = (temp_input - 273.15) * 9/5 + 32
41
+ st.write(f"{temp_input:.2f} K is equal to {converted_temp:.2f}°F.")