SHAMIL SHAHBAZ AWAN
Create app.py
6195db8 verified
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? πŸš€")