mishiawan commited on
Commit
2c01839
·
verified ·
1 Parent(s): 74aadc5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+ from unit_conversion_program import *
5
+
6
+ st.title("Unit Conversion Tool")
7
+ st.write("Select a category and conversion to perform the desired unit transformation.")
8
+
9
+ # Define categories and available conversions
10
+ categories = {
11
+ "Length": [("Micrometers to Nanometers", micrometers_to_nanometers),
12
+ ("Angstroms to Nanometers", angstroms_to_nanometers),
13
+ ("Light-Years to Kilometers", light_years_to_kilometers)],
14
+ "Mass": [("Tons (US) to Kilograms", tons_us_to_kilograms)],
15
+ # Add more categories and conversions as needed
16
+ }
17
+
18
+ # Select a category
19
+ category = st.selectbox("Select a category:", list(categories.keys()))
20
+
21
+ if category:
22
+ # Select a conversion
23
+ conversions = categories[category]
24
+ conversion_name = st.selectbox("Select a conversion:", [c[0] for c in conversions])
25
+ func = {c[0]: c[1] for c in conversions}[conversion_name]
26
+
27
+ # Input the value to convert
28
+ value = st.number_input(f"Enter value for {conversion_name}:", min_value=0.0)
29
+
30
+ # Perform conversion
31
+ if st.button("Convert"):
32
+ result = func(value)
33
+ st.success(f"Result: {result}")