engrmuhammadrizwan01 commited on
Commit
0ca044c
·
verified ·
1 Parent(s): 5c534be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -35
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("🧱 Blocks Quantity Calculation")
6
 
7
- unit = st.selectbox("Select Unit", ["m", "cm"])
8
 
9
- def convert_to_m(val, unit):
10
  return val / 100 if unit == "cm" else val
11
 
12
- st.subheader("Dimension of Wall")
13
- wall_length = convert_to_m(st.number_input("Wall Length (L)", value=0.0), unit)
14
- wall_height = convert_to_m(st.number_input("Wall Height (H)", value=0.0), unit)
15
- wall_thickness = convert_to_m(st.number_input("Wall Thickness (T)", value=0.0), unit)
 
16
 
17
- st.subheader("Dimension of Block")
18
- block_length = convert_to_m(st.number_input("Block Length", value=0.0), unit)
19
- block_width = convert_to_m(st.number_input("Block Width", value=0.0), unit)
20
- block_height = convert_to_m(st.number_input("Block Height", value=0.0), unit)
 
21
 
22
- st.subheader("Mortar Ratio")
23
- cement_ratio = st.number_input("Cement", value=1.0)
24
- sand_ratio = st.number_input("Sand", value=2.5)
25
- ratio_total = cement_ratio + sand_ratio
 
26
 
27
- subtract_area = st.number_input("Subtract Area (Windows/Doors) in m²", value=0.0)
28
- block_price = st.number_input("Block Price (per unit)", value=0.0)
 
 
29
 
30
  if st.button("Calculate"):
31
- wall_volume = wall_length * wall_height * wall_thickness - subtract_area
32
- block_volume = block_length * block_height * block_width
33
- number_of_blocks = wall_volume / block_volume
34
- dry_mortar_volume = wall_volume * 0.21
35
- cement_volume = dry_mortar_volume * (cement_ratio / ratio_total)
36
- sand_volume = dry_mortar_volume * (sand_ratio / ratio_total)
37
- cement_bags = cement_volume / 0.0347
38
- total_cost = number_of_blocks * block_price
39
-
40
- st.markdown("### 📋 Results")
41
- st.write(f"**Wall Volume:** {wall_volume:.2f} m³")
42
- st.write(f"**Number of Blocks:** {number_of_blocks:.2f}")
43
- st.write(f"**Dry Mortar:** {dry_mortar_volume:.2f} m³")
44
- st.write(f"**Cement Volume:** {cement_volume:.2f} m³")
45
- st.write(f"**Sand Volume:** {sand_volume:.2f} m³")
46
- st.write(f"**Cement Bags (50kg):** {cement_bags:.2f} bags")
47
- st.write(f"**Blocks Cost:** ${total_cost:.2f}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_**