Bill_Splitter / app.py
temii001's picture
Create app.py
7061a38 verified
import streamlit as st
def calculate_tip(total_amount, people, tip_percent):
tip = total_amount * (tip_percent / 100)
grand_total = total_amount + tip
per_person = grand_total / people
return tip, grand_total, per_person
def main():
st.set_page_config(page_title="Bill Splitter", page_icon="πŸ’Έ")
st.title("πŸ’Έ Bill Splitter + Tip Calculator")
st.markdown("Split your bill with friends & add a fair tip.")
total_amount = st.number_input("Total Bill Amount (PKR)", min_value=0.0, step=50.0, format="%.2f")
people = st.number_input("Number of People", min_value=1, step=1)
tip_percent = st.slider("Tip Percentage", min_value=0, max_value=50, value=10)
if st.button("Calculate"):
tip, grand_total, per_person = calculate_tip(total_amount, people, tip_percent)
st.success(f"πŸ’° Tip: PKR {tip:.2f}")
st.info(f"🧾 Grand Total: PKR {grand_total:.2f}")
st.success(f"πŸ‘₯ Each Person Pays: PKR {per_person:.2f}")
if tip_percent < 5:
st.caption("🧊 Cold-hearted tipping πŸ˜…")
elif tip_percent <= 15:
st.caption("🫑 Standard tipper β€” you're good.")
else:
st.caption("πŸ’Ž Generous boss vibes!")
if __name__ == "__main__":
main()