Spaces:
Sleeping
Sleeping
Download app.py from SyedaRidaAI/shopping_discount_app: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/SyedaRidaAI/shopping_discount_app/resolve/main/app.py
- Command line
-
hf download hf://spaces/SyedaRidaAI/shopping_discount_app/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SyedaRidaAI/shopping_discount_app/resolve/main/app.py
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!") | |