Mtkhang90's picture
Update app.py
103c6a1 verified
import streamlit as st
st.set_page_config(page_title="🏠 House Material & Cost Estimator", page_icon="πŸ› ", layout="centered")
st.title("🏠 House Material & Cost Estimator")
st.write("Plan your building project with estimated materials and cost.")
# Inputs
house_area = st.number_input('Enter the total house area (in square feet)', min_value=100)
house_type = st.selectbox(
'Select the house type',
('Single Story', 'Double Story', 'Luxury')
)
# Material ratios based on house type (per 1000 sq ft)
material_ratios = {
"Single Story": {
"Bricks (units)": 8000,
"Cement (bags)": 400,
"Sand (tons)": 15,
"Steel (tons)": 5,
"Gravel (tons)": 20,
"Wood (cubic feet)": 500
},
"Double Story": {
"Bricks (units)": 12000,
"Cement (bags)": 600,
"Sand (tons)": 22,
"Steel (tons)": 8,
"Gravel (tons)": 30,
"Wood (cubic feet)": 700
},
"Luxury": {
"Bricks (units)": 10000,
"Cement (bags)": 500,
"Sand (tons)": 20,
"Steel (tons)": 7,
"Gravel (tons)": 25,
"Wood (cubic feet)": 1000
}
}
# Basic cost estimates (example rates)
cost_per_unit = {
"Bricks (units)": 10, # per brick
"Cement (bags)": 8, # per bag
"Sand (tons)": 50, # per ton
"Steel (tons)": 700, # per ton
"Gravel (tons)": 40, # per ton
"Wood (cubic feet)": 15 # per cubic foot
}
if st.button('Estimate Materials and Cost'):
st.subheader("πŸ“¦ Estimated Materials Needed:")
factor = house_area / 1000
total_cost = 0
for material, base_amount in material_ratios[house_type].items():
required = base_amount * factor
cost = required * cost_per_unit[material]
total_cost += cost
st.write(f"- **{material}**: {required:.2f} (Cost: ${cost:,.2f})")
st.subheader(f"πŸ’° Total Estimated Cost: **${total_cost:,.2f}**")
st.info("⚑ This is a rough estimate. Actual requirements and prices may vary based on location and design.")
st.markdown("---")
st.caption("Built with ❀️ using Streamlit")