ai-lover's picture
Update app.py
f67aac1 verified
import streamlit as st
# App title
st.title("Brick Estimator")
st.markdown("""
### Estimate the number of bricks and mortar required for your wall!
Just input the dimensions of the wall and bricks to get started.
""")
# Input fields for wall dimensions
st.header("Wall Dimensions")
wall_length = st.number_input("Wall Length (meters):", min_value=0.0, value=0.0, step=0.1)
wall_height = st.number_input("Wall Height (meters):", min_value=0.0, value=0.0, step=0.1)
wall_thickness = st.number_input("Wall Thickness (meters):", min_value=0.0, value=0.0, step=0.01)
# Input fields for brick dimensions
st.header("Brick Dimensions")
brick_length = st.number_input("Brick Length (meters):", min_value=0.0, value=0.0, step=0.01)
brick_height = st.number_input("Brick Height (meters):", min_value=0.0, value=0.0, step=0.01)
brick_width = st.number_input("Brick Width (meters):", min_value=0.0, value=0.0, step=0.01)
# Mortar percentage
mortar_percentage = st.slider("Mortar as % of Wall Volume:", min_value=0, max_value=20, value=10, step=1)
# Calculate the number of bricks and mortar
if st.button("Calculate"):
if wall_length > 0 and wall_height > 0 and wall_thickness > 0 and \
brick_length > 0 and brick_height > 0 and brick_width > 0:
# Wall and brick volumes
wall_volume = wall_length * wall_height * wall_thickness
brick_volume = brick_length * brick_height * brick_width
# Number of bricks
number_of_bricks = wall_volume / brick_volume
mortar_volume = (mortar_percentage / 100) * wall_volume
st.success(f"Total Number of Bricks: {number_of_bricks:.0f}")
st.success(f"Volume of Mortar Required: {mortar_volume:.2f} cubic meters")
else:
st.warning("Please enter all dimensions greater than zero!")