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