SyedaRidaAI's picture
Create app.py
32b39a8 verified
Raw History Blame Contribute Delete
1.24 kB
import streamlit as st
# Set Streamlit page title
st.set_page_config(page_title="🛍️ Shopping Discount Calculator", layout="centered")
# App heading
st.title("🛍️ Shopping Discount Calculator")
# Input field for total amount
total_amount = st.number_input("Enter your total shopping amount (PKR):", min_value=0)
# Button to calculate discount
if st.button("Calculate Discount"):
discount = 0 # initialize discount
final_price = total_amount # default final price
# Check discount conditions
if total_amount >= 20000:
discount = 0.40 # 40% discount
elif total_amount >= 10000:
discount = 0.20 # 20% discount
# Apply discount if any
if discount > 0:
discount_amount = total_amount * discount
final_price = total_amount - discount_amount
st.success(f"🎉 You got a {int(discount * 100)}% discount!")
st.write(f"🧾 Discount Amount: PKR {discount_amount:.2f}")
else:
st.info("No discount applied. Shop more to unlock discounts!")
# Show final price after discount
st.write(f"💰 Final Price to Pay: PKR {final_price:.2f}")
# Thank you message
st.markdown("---")
st.success("🙏 Thank you for visiting our outlet!")