Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,77 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
st.set_page_config(page_title="Block Quantity Calculator", layout="centered")
|
| 4 |
|
| 5 |
-
st.title("🧱
|
| 6 |
|
| 7 |
-
unit = st.selectbox("
|
| 8 |
|
| 9 |
-
def
|
| 10 |
return val / 100 if unit == "cm" else val
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
|
| 30 |
if st.button("Calculate"):
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
cement_bags =
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
st.markdown("
|
| 41 |
-
|
| 42 |
-
st.
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
st.set_page_config(page_title="🧱 Block Quantity Calculator", layout="centered")
|
| 4 |
|
| 5 |
+
st.title("🧱 Block Quantity Calculator")
|
| 6 |
|
| 7 |
+
unit = st.selectbox("Choose Unit", ["m", "cm"])
|
| 8 |
|
| 9 |
+
def convert(val):
|
| 10 |
return val / 100 if unit == "cm" else val
|
| 11 |
|
| 12 |
+
# Wall Dimensions
|
| 13 |
+
st.subheader("Wall Dimensions")
|
| 14 |
+
L = convert(st.number_input("Wall Length", value=0.0))
|
| 15 |
+
H = convert(st.number_input("Wall Height", value=0.0))
|
| 16 |
+
T = convert(st.number_input("Wall Thickness", value=0.0))
|
| 17 |
|
| 18 |
+
# Block Dimensions
|
| 19 |
+
st.subheader("Block Dimensions")
|
| 20 |
+
BL = convert(st.number_input("Block Length", value=0.0))
|
| 21 |
+
BH = convert(st.number_input("Block Height", value=0.0))
|
| 22 |
+
BW = convert(st.number_input("Block Width", value=0.0))
|
| 23 |
|
| 24 |
+
# Mortar Ratio
|
| 25 |
+
st.subheader("Cement-Sand Ratio")
|
| 26 |
+
cement = st.number_input("Cement Ratio", value=1.0)
|
| 27 |
+
sand = st.number_input("Sand Ratio", value=2.5)
|
| 28 |
+
ratio_sum = cement + sand
|
| 29 |
|
| 30 |
+
# Other Inputs
|
| 31 |
+
st.subheader("Additional Inputs")
|
| 32 |
+
deduct_area = st.number_input("Deducted Area (e.g., windows/doors) in m²", value=0.0)
|
| 33 |
+
block_price = st.number_input("Block Price (optional)", value=0.0)
|
| 34 |
|
| 35 |
if st.button("Calculate"):
|
| 36 |
+
wall_vol = (L * H * T) - deduct_area
|
| 37 |
+
block_vol = BL * BH * BW
|
| 38 |
+
num_blocks = wall_vol / block_vol
|
| 39 |
+
dry_mortar = wall_vol * 0.21
|
| 40 |
+
cement_vol = dry_mortar * (cement / ratio_sum)
|
| 41 |
+
sand_vol = dry_mortar * (sand / ratio_sum)
|
| 42 |
+
cement_bags = cement_vol / 0.0347
|
| 43 |
+
cost = num_blocks * block_price
|
| 44 |
+
|
| 45 |
+
st.markdown("## 📘 Calculation Breakdown")
|
| 46 |
+
|
| 47 |
+
st.markdown(f"""
|
| 48 |
+
### 🧱 Wall Volume
|
| 49 |
+
**Formula:** `Length × Height × Thickness - Deducted Area`
|
| 50 |
+
**=** {L:.2f} × {H:.2f} × {T:.2f} - {deduct_area:.2f}
|
| 51 |
+
**= {wall_vol:.2f} m³**
|
| 52 |
+
|
| 53 |
+
### 🧱 Block Volume
|
| 54 |
+
**Formula:** `Length × Height × Width`
|
| 55 |
+
**=** {BL:.2f} × {BH:.2f} × {BW:.2f}
|
| 56 |
+
**= {block_vol:.4f} m³**
|
| 57 |
+
|
| 58 |
+
### 🔢 Number of Blocks
|
| 59 |
+
**Formula:** `Wall Volume ÷ Block Volume`
|
| 60 |
+
**=** {wall_vol:.2f} ÷ {block_vol:.4f}
|
| 61 |
+
**= {num_blocks:.0f} blocks**
|
| 62 |
+
|
| 63 |
+
### 🧪 Dry Mortar Volume
|
| 64 |
+
**Formula:** `Wall Volume × 0.21`
|
| 65 |
+
**=** {wall_vol:.2f} × 0.21
|
| 66 |
+
**= {dry_mortar:.2f} m³**
|
| 67 |
+
|
| 68 |
+
### 🧱 Cement & Sand Volume
|
| 69 |
+
**Cement Volume:**
|
| 70 |
+
**=** {dry_mortar:.2f} × ({cement} / {ratio_sum}) = {cement_vol:.2f} m³
|
| 71 |
+
**Sand Volume:**
|
| 72 |
+
**=** {dry_mortar:.2f} × ({sand} / {ratio_sum}) = {sand_vol:.2f} m³
|
| 73 |
+
|
| 74 |
+
### 🧱 Cement Bags
|
| 75 |
+
**Formula:** `Cement Volume ÷ 0.0347`
|
| 76 |
+
**=** {cement_vol:.2f} ÷ 0.0347
|
| 77 |
+
**= {cement_bags:.0f} bags_**
|