SHAMIL SHAHBAZ AWAN commited on
Commit
6195db8
·
verified ·
1 Parent(s): 0a7d5a9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Planet gravity dictionary relative to Earth
4
+ planet_gravity = {
5
+ "Mercury": 0.38,
6
+ "Venus": 0.91,
7
+ "Earth": 1.00,
8
+ "Moon": 0.166,
9
+ "Mars": 0.38,
10
+ "Jupiter": 2.34,
11
+ "Saturn": 1.06,
12
+ "Uranus": 0.92,
13
+ "Neptune": 1.19,
14
+ "Pluto": 0.06
15
+ }
16
+
17
+ # Streamlit UI
18
+ st.set_page_config(page_title="Planetary Weight Calculator 🌌", layout="centered")
19
+ st.title("🌍 Planetary Weight Calculator")
20
+ st.write("Enter your weight on Earth and find out how much you'd weigh on other celestial bodies!")
21
+
22
+ # User input
23
+ earth_weight = st.number_input("Enter your weight on Earth (in kg):", min_value=1.0, step=0.5)
24
+
25
+ if earth_weight:
26
+ planet = st.selectbox("Select a planet or celestial body:", list(planet_gravity.keys()))
27
+ calc_button = st.button("Calculate Weight")
28
+
29
+ if calc_button:
30
+ new_weight = earth_weight * planet_gravity[planet]
31
+ st.success(f"Your weight on **{planet}** would be **{new_weight:.2f} kg** 🪐")
32
+
33
+ st.markdown("---")
34
+ st.markdown("Created with ❤️ using Streamlit. Ready for space travel? 🚀")